Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 648adda

Browse files
committed
Bug 1249389 - part 0 - use getter_Transfers in TestStartupCache.cpp; r=erahm
TestWriteObject() in TestStartupCache.cpp uses this odd pattern of acquiring a raw pointer from the startup cache, and then stashing that raw pointer into an nsAutoArrayPtr. We can do better by using the getter_Transfers idiom and thereby always using the smart pointer.
1 parent fd4ebed commit 648adda

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

startupcache/test/TestStartupCache.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,9 @@ TestWriteObject() {
195195
return rv;
196196
}
197197

198-
char* bufPtr = nullptr;
199198
nsAutoArrayPtr<char> buf;
200199
uint32_t len;
201-
NewBufferFromStorageStream(storageStream, &bufPtr, &len);
202-
buf = bufPtr;
200+
NewBufferFromStorageStream(storageStream, getter_Transfers(buf), &len);
203201

204202
// Since this is a post-startup write, it should be written and
205203
// available.
@@ -209,16 +207,14 @@ TestWriteObject() {
209207
return rv;
210208
}
211209

212-
char* buf2Ptr = nullptr;
213210
nsAutoArrayPtr<char> buf2;
214211
uint32_t len2;
215212
nsCOMPtr<nsIObjectInputStream> objectInput;
216-
rv = sc->GetBuffer(id, &buf2Ptr, &len2);
213+
rv = sc->GetBuffer(id, getter_Transfers(buf2), &len2);
217214
if (NS_FAILED(rv)) {
218215
fail("failed to retrieve buffer");
219216
return rv;
220217
}
221-
buf2 = buf2Ptr;
222218

223219
rv = NewObjectInputStreamFromBuffer(buf2, len2, getter_AddRefs(objectInput));
224220
if (NS_FAILED(rv)) {

0 commit comments

Comments
 (0)