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.
This commit is contained in:
Nathan Froyd 2016-02-18 11:22:12 -05:00
parent fd4ebed1e5
commit 648addac4e

View File

@ -195,11 +195,9 @@ TestWriteObject() {
return rv;
}
char* bufPtr = nullptr;
nsAutoArrayPtr<char> buf;
uint32_t len;
NewBufferFromStorageStream(storageStream, &bufPtr, &len);
buf = bufPtr;
NewBufferFromStorageStream(storageStream, getter_Transfers(buf), &len);
// Since this is a post-startup write, it should be written and
// available.
@ -209,16 +207,14 @@ TestWriteObject() {
return rv;
}
char* buf2Ptr = nullptr;
nsAutoArrayPtr<char> buf2;
uint32_t len2;
nsCOMPtr<nsIObjectInputStream> objectInput;
rv = sc->GetBuffer(id, &buf2Ptr, &len2);
rv = sc->GetBuffer(id, getter_Transfers(buf2), &len2);
if (NS_FAILED(rv)) {
fail("failed to retrieve buffer");
return rv;
}
buf2 = buf2Ptr;
rv = NewObjectInputStreamFromBuffer(buf2, len2, getter_AddRefs(objectInput));
if (NS_FAILED(rv)) {