Bug 1232374 - remove nsAutoArrayPtr usages from toolkit/; r=froydnj

This commit is contained in:
Haik Aftandilian 2015-12-17 09:37:47 -08:00
parent e9b726a965
commit b184ba27ca
4 changed files with 15 additions and 19 deletions

View File

@ -13,6 +13,7 @@
#include "nsILocalFileWin.h"
#include "nsArrayUtils.h"
#include "nsIXULAppInfo.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/WindowsVersion.h"
using namespace mozilla;
@ -248,9 +249,7 @@ nsParentalControlsService::RequestURIOverrides(nsIArray *aTargets, nsIInterfaceR
// Allocate an array of sub uri
int32_t count = arrayLength - 1;
nsAutoArrayPtr<LPCWSTR> arrUrls(new LPCWSTR[count]);
if (!arrUrls)
return NS_ERROR_OUT_OF_MEMORY;
auto arrUrls = MakeUnique<LPCWSTR[]>(count);
uint32_t uriIdx = 0, idx;
for (idx = 1; idx < arrayLength; idx++)

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ArrayUtils.h"
#include "mozilla/UniquePtr.h"
#include <stdio.h>
#include <stdlib.h>
@ -971,12 +972,10 @@ nsToolkitProfileService::Flush()
uint32_t length;
const int bufsize = 100+MAXPATHLEN*pCount;
nsAutoArrayPtr<char> buffer (new char[bufsize]);
auto buffer = MakeUnique<char[]>(bufsize);
NS_ENSURE_TRUE(buffer, NS_ERROR_OUT_OF_MEMORY);
char *pos = buffer;
char *end = buffer + bufsize;
char *pos = buffer.get();
char *end = pos + bufsize;
pos += snprintf(pos, end - pos,
"[General]\n"
@ -1024,13 +1023,11 @@ nsToolkitProfileService::Flush()
rv = mListFile->OpenANSIFileDesc("w", &writeFile);
NS_ENSURE_SUCCESS(rv, rv);
if (buffer) {
length = pos - buffer;
length = pos - buffer.get();
if (fwrite(buffer, sizeof(char), length, writeFile) != length) {
fclose(writeFile);
return NS_ERROR_UNEXPECTED;
}
if (fwrite(buffer.get(), sizeof(char), length, writeFile) != length) {
fclose(writeFile);
return NS_ERROR_UNEXPECTED;
}
fclose(writeFile);

View File

@ -4,7 +4,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsArrayUtils.h"
#include "nsAutoPtr.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsISupportsPrimitives.h"
@ -12,6 +11,7 @@
#include "nsString.h"
#include "prlink.h"
#include "mozilla/unused.h"
#include "mozilla/UniquePtr.h"
#include <glib.h>
#include <glib-object.h>
@ -216,7 +216,7 @@ nsPackageKitService::InstallPackages(uint32_t aInstallMethod,
// Create the GVariant* parameter from the list of packages.
GVariant* parameters = nullptr;
nsAutoArrayPtr<gchar*> packages(new gchar*[arrayLength + 1]);
auto packages = MakeUnique<gchar*[]>(arrayLength + 1);
nsresult rv = NS_OK;
for (uint32_t i = 0; i < arrayLength; i++) {

View File

@ -6,8 +6,8 @@
#include "MacLaunchHelper.h"
#include "nsMemory.h"
#include "nsAutoPtr.h"
#include "nsIAppStartup.h"
#include "mozilla/UniquePtr.h"
#include <stdio.h>
#include <spawn.h>
@ -40,7 +40,7 @@ void LaunchChildMac(int aArgc, char** aArgv,
{
// "posix_spawnp" uses null termination for arguments rather than a count.
// Note that we are not duplicating the argument strings themselves.
nsAutoArrayPtr<char*> argv_copy(new char*[aArgc + 1]);
auto argv_copy = MakeUnique<char*[]>(aArgc + 1);
for (int i = 0; i < aArgc; i++) {
argv_copy[i] = aArgv[i];
}
@ -80,7 +80,7 @@ void LaunchChildMac(int aArgc, char** aArgv,
envp = *cocoaEnvironment;
}
int result = posix_spawnp(pid, argv_copy[0], NULL, &spawnattr, argv_copy, envp);
int result = posix_spawnp(pid, argv_copy[0], NULL, &spawnattr, argv_copy.get(), envp);
posix_spawnattr_destroy(&spawnattr);