From 0c179067770eb88cf7ba21deb7c6ead8f29d69b5 Mon Sep 17 00:00:00 2001 From: Eric Rahm Date: Fri, 28 Feb 2020 21:44:12 +0000 Subject: [PATCH] Bug 1618753 Remove nsAutoPtr usage from modules. r=KrisWright Differential Revision: https://phabricator.services.mozilla.com/D64704 --HG-- extra : moz-landing-system : lando --- modules/libjar/nsZipArchive.cpp | 2 +- modules/libjar/nsZipArchive.h | 3 +-- modules/libpref/Preferences.cpp | 14 +++++--------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/modules/libjar/nsZipArchive.cpp b/modules/libjar/nsZipArchive.cpp index 7293c6be532b..7653789e60bd 100644 --- a/modules/libjar/nsZipArchive.cpp +++ b/modules/libjar/nsZipArchive.cpp @@ -234,7 +234,7 @@ nsresult nsZipHandle::Init(nsZipArchive* zip, const char* entry, RefPtr handle = new nsZipHandle(); if (!handle) return NS_ERROR_OUT_OF_MEMORY; - handle->mBuf = new nsZipItemPtr(zip, entry); + handle->mBuf = MakeUnique>(zip, entry); if (!handle->mBuf) return NS_ERROR_OUT_OF_MEMORY; if (!handle->mBuf->Buffer()) return NS_ERROR_UNEXPECTED; diff --git a/modules/libjar/nsZipArchive.h b/modules/libjar/nsZipArchive.h index 6424fd279ea9..5b291f8d62a1 100644 --- a/modules/libjar/nsZipArchive.h +++ b/modules/libjar/nsZipArchive.h @@ -14,7 +14,6 @@ #include "zlib.h" #include "zipstruct.h" -#include "nsAutoPtr.h" #include "nsIFile.h" #include "nsISupportsImpl.h" // For mozilla::ThreadSafeAutoRefCnt #include "mozilla/ArenaAllocator.h" @@ -403,7 +402,7 @@ class nsZipHandle final { PRFileMap* mMap; /* nspr datastructure for mmap */ mozilla::AutoFDClose mNSPRFileDesc; - nsAutoPtr > mBuf; + UniquePtr > mBuf; mozilla::ThreadSafeAutoRefCnt mRefCnt; /* ref count */ NS_DECL_OWNINGTHREAD diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index ba821e5b141d..8f5a5f3b5d9c 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -45,7 +45,6 @@ #include "mozilla/Variant.h" #include "mozilla/Vector.h" #include "nsAppDirectoryServiceDefs.h" -#include "nsAutoPtr.h" #include "nsCategoryManagerUtils.h" #include "nsClassHashtable.h" #include "nsCOMArray.h" @@ -4301,16 +4300,14 @@ static nsresult pref_ReadPrefFromJar(nsZipArchive* aJarReader, static nsresult pref_ReadDefaultPrefs(const RefPtr jarReader, const char* path) { - nsZipFind* findPtr; - nsAutoPtr find; + UniquePtr find; nsTArray prefEntries; const char* entryName; uint16_t entryNameLen; - nsresult rv = jarReader->FindInit(path, &findPtr); + nsresult rv = jarReader->FindInit(path, getter_Transfers(find)); NS_ENSURE_SUCCESS(rv, rv); - find = findPtr; while (NS_SUCCEEDED(find->FindNext(&entryName, &entryNameLen))) { prefEntries.AppendElement(Substring(entryName, entryNameLen)); } @@ -4473,8 +4470,7 @@ nsresult Preferences::InitInitialObjects(bool aIsStartup) { // preferences from omni.jar, whether or not `$app == $gre`. nsresult rv = NS_ERROR_FAILURE; - nsZipFind* findPtr; - nsAutoPtr find; + UniquePtr find; nsTArray prefEntries; const char* entryName; uint16_t entryNameLen; @@ -4570,9 +4566,9 @@ nsresult Preferences::InitInitialObjects(bool aIsStartup) { } if (appJarReader) { - rv = appJarReader->FindInit("defaults/preferences/*.js$", &findPtr); + rv = appJarReader->FindInit("defaults/preferences/*.js$", + getter_Transfers(find)); NS_ENSURE_SUCCESS(rv, rv); - find = findPtr; prefEntries.Clear(); while (NS_SUCCEEDED(find->FindNext(&entryName, &entryNameLen))) { prefEntries.AppendElement(Substring(entryName, entryNameLen));