Bug 1249389 - part 0 - use getter_Transfers in TestStartupCache.cpp; r=erahm
authorNathan Froyd <froydnj@mozilla.com>
Thu, 18 Feb 2016 11:22:12 -0500
changeset 321782 615be94be0865921a73a7d2f81fbdb6bb1640bc6
parent 321781 6104903f75c5f154cc6c5e8d89dbf0a279284e59
child 321783 b688e63090589bcee8766ea557f1a74682c020d5
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1249389
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
--- a/startupcache/test/TestStartupCache.cpp
+++ b/startupcache/test/TestStartupCache.cpp
@@ -190,40 +190,36 @@ TestWriteObject() {
   }
   nsCOMPtr<nsISupports> objQI(do_QueryInterface(obj));
   rv = objectOutput->WriteObject(objQI, true);
   if (NS_FAILED(rv)) {
     fail("failed to write object");
     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.
   rv = sc->PutBuffer(id, buf, len);
   if (NS_FAILED(rv)) {
     fail("failed to insert input stream");
     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)) {
     fail("failed to created input stream");
     return rv;
   }  
   buf2.forget();