From 648addac4eda5fdb794c4073ce31b36dfe60d632 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Thu, 18 Feb 2016 11:22:12 -0500 Subject: [PATCH] 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. --- startupcache/test/TestStartupCache.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/startupcache/test/TestStartupCache.cpp b/startupcache/test/TestStartupCache.cpp index a1cdef821586..e7102c5c38d8 100644 --- a/startupcache/test/TestStartupCache.cpp +++ b/startupcache/test/TestStartupCache.cpp @@ -195,11 +195,9 @@ TestWriteObject() { return rv; } - char* bufPtr = nullptr; nsAutoArrayPtr 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 buf2; uint32_t len2; nsCOMPtr 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)) {