mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-22 12:04:38 +00:00
Bug 1134923 - Remove NS_Alloc/NS_Realloc/NS_Free. r=nfroyd
They are kept around for the sake of the standalone glue, which is used for e.g. webapprt, which doesn't have direct access to jemalloc, and thus still needs a wrapper to go through the xpcom function list and get to jemalloc from there.
This commit is contained in:
parent
c8ff2d51c8
commit
924c9eb636
@ -110,7 +110,7 @@ Crypto::GetRandomValues(JSContext* aCx, const ArrayBufferView& aArray,
|
||||
}
|
||||
|
||||
memcpy(data, buf, dataLen);
|
||||
NS_Free(buf);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
aRetval.set(view);
|
||||
|
@ -758,7 +758,7 @@ private:
|
||||
// Unfortunately we've to copy the data first since all our strings are
|
||||
// going to free it. We also need fallible alloc, so we can't just use
|
||||
// ToNewCString().
|
||||
char* copy = static_cast<char*>(NS_Alloc(body.Length()));
|
||||
char* copy = static_cast<char*>(moz_xmalloc(body.Length()));
|
||||
if (!copy) {
|
||||
NS_WARNING("Failed to copy File entry body.");
|
||||
return false;
|
||||
|
@ -2323,7 +2323,7 @@ HTMLInputElement::MozGetFileNameArray(uint32_t* aLength, char16_t*** aFileNames)
|
||||
|
||||
*aLength = array.Length();
|
||||
char16_t** ret =
|
||||
static_cast<char16_t**>(NS_Alloc(*aLength * sizeof(char16_t*)));
|
||||
static_cast<char16_t**>(moz_xmalloc(*aLength * sizeof(char16_t*)));
|
||||
if (!ret) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -1028,7 +1028,7 @@ UndoManager::ItemInternal(uint32_t aIndex,
|
||||
aItems.AppendElement(static_cast<DOMTransaction*>(listData[i]));
|
||||
NS_RELEASE(listData[i]);
|
||||
}
|
||||
NS_Free(listData);
|
||||
free(listData);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -21268,8 +21268,6 @@ ObjectStoreAddOrPutRequestOp::DoDatabaseWork(DatabaseConnection* aConnection)
|
||||
{
|
||||
size_t compressedLength = snappy::MaxCompressedLength(uncompressedLength);
|
||||
|
||||
// malloc is equivalent to NS_Alloc, which we use because mozStorage
|
||||
// expects to be able to free the adopted pointer with NS_Free.
|
||||
char* compressed = static_cast<char*>(malloc(compressedLength));
|
||||
if (NS_WARN_IF(!compressed)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -4049,7 +4049,7 @@ ContentParent::RecvGetRandomValues(const uint32_t& length,
|
||||
|
||||
memcpy(randomValues->Elements(), buf, length);
|
||||
|
||||
NS_Free(buf);
|
||||
free(buf);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -344,7 +344,7 @@ nsJSONWriter::WriteToStream(nsIOutputStream *aStream,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// create the buffer we need
|
||||
char* destBuf = (char *) NS_Alloc(aDestLength);
|
||||
char* destBuf = (char *) moz_xmalloc(aDestLength);
|
||||
if (!destBuf)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
@ -352,7 +352,7 @@ nsJSONWriter::WriteToStream(nsIOutputStream *aStream,
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = aStream->Write(destBuf, aDestLength, &bytesWritten);
|
||||
|
||||
NS_Free(destBuf);
|
||||
free(destBuf);
|
||||
mDidWrite = true;
|
||||
|
||||
return rv;
|
||||
|
@ -97,7 +97,7 @@ public:
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (elementType != nsIDataType::VTYPE_INTERFACE) {
|
||||
NS_Free(rawArray);
|
||||
free(rawArray);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ public:
|
||||
devices.AppendElement(device);
|
||||
NS_IF_RELEASE(supportsArray[i]); // explicitly decrease refcount for rawptr
|
||||
}
|
||||
NS_Free(rawArray); // explicitly free memory from nsIVariant::GetAsArray
|
||||
free(rawArray); // explicitly free memory from nsIVariant::GetAsArray
|
||||
}
|
||||
nsTArray<nsRefPtr<MediaDeviceInfo>> infos;
|
||||
for (auto& device : devices) {
|
||||
|
@ -357,7 +357,7 @@ MediaDeviceSuccessCallback::OnSuccess(nsIVariant* aDevices)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (elementType != nsIDataType::VTYPE_INTERFACE) {
|
||||
NS_Free(rawArray);
|
||||
free(rawArray);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -370,7 +370,7 @@ MediaDeviceSuccessCallback::OnSuccess(nsIVariant* aDevices)
|
||||
devices.AppendElement(device);
|
||||
NS_IF_RELEASE(supportsArray[i]); // explicitly decrease reference count for raw pointer
|
||||
}
|
||||
NS_Free(rawArray); // explicitly free for the memory from nsIVariant::GetAsArray
|
||||
free(rawArray); // explicitly free for the memory from nsIVariant::GetAsArray
|
||||
|
||||
// Send MediaPermissionRequest
|
||||
nsRefPtr<MediaPermissionRequest> req = new MediaPermissionRequest(mRequest, devices);
|
||||
|
@ -280,7 +280,7 @@ GenerateRandomName(nsCString& aOutSalt, uint32_t aLength)
|
||||
nsDependentCSubstring randomData(reinterpret_cast<const char*>(buffer),
|
||||
requiredBytesLength);
|
||||
rv = Base64Encode(randomData, temp);
|
||||
NS_Free(buffer);
|
||||
free(buffer);
|
||||
buffer = nullptr;
|
||||
if (NS_FAILED (rv)) return rv;
|
||||
|
||||
|
@ -243,10 +243,10 @@ PluginPRLibrary::NPP_GetSitesWithData(InfallibleTArray<nsCString>& result)
|
||||
char** iterator = sites;
|
||||
while (*iterator) {
|
||||
result.AppendElement(*iterator);
|
||||
NS_Free(*iterator);
|
||||
free(*iterator);
|
||||
++iterator;
|
||||
}
|
||||
NS_Free(sites);
|
||||
free(sites);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1848,7 +1848,7 @@ _releasevariantvalue(NPVariant* variant)
|
||||
}
|
||||
}
|
||||
#else
|
||||
NS_Free((void *)s->UTF8Characters);
|
||||
free((void *)s->UTF8Characters);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
@ -230,19 +230,19 @@ nsNPAPIPluginInstance::~nsNPAPIPluginInstance()
|
||||
|
||||
for (uint32_t i = 0; i < mCachedParamLength; i++) {
|
||||
if (mCachedParamNames[i]) {
|
||||
NS_Free(mCachedParamNames[i]);
|
||||
free(mCachedParamNames[i]);
|
||||
mCachedParamNames[i] = nullptr;
|
||||
}
|
||||
if (mCachedParamValues[i]) {
|
||||
NS_Free(mCachedParamValues[i]);
|
||||
free(mCachedParamValues[i]);
|
||||
mCachedParamValues[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
NS_Free(mCachedParamNames);
|
||||
free(mCachedParamNames);
|
||||
mCachedParamNames = nullptr;
|
||||
|
||||
NS_Free(mCachedParamValues);
|
||||
free(mCachedParamValues);
|
||||
mCachedParamValues = nullptr;
|
||||
}
|
||||
|
||||
@ -454,8 +454,8 @@ nsNPAPIPluginInstance::Start()
|
||||
uint32_t quirkParamLength = params.Length() ?
|
||||
mCachedParamLength : attributes.Length();
|
||||
|
||||
mCachedParamNames = (char**)NS_Alloc(sizeof(char*) * mCachedParamLength);
|
||||
mCachedParamValues = (char**)NS_Alloc(sizeof(char*) * mCachedParamLength);
|
||||
mCachedParamNames = (char**)moz_xmalloc(sizeof(char*) * mCachedParamLength);
|
||||
mCachedParamValues = (char**)moz_xmalloc(sizeof(char*) * mCachedParamLength);
|
||||
|
||||
for (uint32_t i = 0; i < attributes.Length(); i++) {
|
||||
mCachedParamNames[i] = ToNewUTF8String(attributes[i].mName);
|
||||
|
@ -557,7 +557,7 @@ nsresult nsPluginHost::PostURL(nsISupports* pluginInst,
|
||||
|
||||
nsCOMPtr<nsIStringInputStream> sis = do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv);
|
||||
if (!sis) {
|
||||
NS_Free(dataToPost);
|
||||
free(dataToPost);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -104,19 +104,19 @@ static char* CFStringRefToUTF8Buffer(CFStringRef cfString)
|
||||
int bufferLength =
|
||||
::CFStringGetMaximumSizeForEncoding(::CFStringGetLength(cfString),
|
||||
kCFStringEncodingUTF8) + 1;
|
||||
char* newBuffer = static_cast<char*>(NS_Alloc(bufferLength));
|
||||
char* newBuffer = static_cast<char*>(moz_xmalloc(bufferLength));
|
||||
if (!newBuffer) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!::CFStringGetCString(cfString, newBuffer, bufferLength,
|
||||
kCFStringEncodingUTF8)) {
|
||||
NS_Free(newBuffer);
|
||||
free(newBuffer);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
newBuffer = static_cast<char*>(NS_Realloc(newBuffer,
|
||||
strlen(newBuffer) + 1));
|
||||
newBuffer = static_cast<char*>(moz_xrealloc(newBuffer,
|
||||
strlen(newBuffer) + 1));
|
||||
return newBuffer;
|
||||
}
|
||||
|
||||
@ -224,15 +224,15 @@ static void ParsePlistPluginInfo(nsPluginInfo& info, CFBundleRef bundle)
|
||||
|
||||
// Allocate memory for mime data
|
||||
int mimeDataArraySize = mimeDictKeyCount * sizeof(char*);
|
||||
info.fMimeTypeArray = static_cast<char**>(NS_Alloc(mimeDataArraySize));
|
||||
info.fMimeTypeArray = static_cast<char**>(moz_xmalloc(mimeDataArraySize));
|
||||
if (!info.fMimeTypeArray)
|
||||
return;
|
||||
memset(info.fMimeTypeArray, 0, mimeDataArraySize);
|
||||
info.fExtensionArray = static_cast<char**>(NS_Alloc(mimeDataArraySize));
|
||||
info.fExtensionArray = static_cast<char**>(moz_xmalloc(mimeDataArraySize));
|
||||
if (!info.fExtensionArray)
|
||||
return;
|
||||
memset(info.fExtensionArray, 0, mimeDataArraySize);
|
||||
info.fMimeDescriptionArray = static_cast<char**>(NS_Alloc(mimeDataArraySize));
|
||||
info.fMimeDescriptionArray = static_cast<char**>(moz_xmalloc(mimeDataArraySize));
|
||||
if (!info.fMimeDescriptionArray)
|
||||
return;
|
||||
memset(info.fMimeDescriptionArray, 0, mimeDataArraySize);
|
||||
@ -350,7 +350,7 @@ nsresult nsPluginFile::LoadPlugin(PRLibrary **outLibrary)
|
||||
static char* p2cstrdup(StringPtr pstr)
|
||||
{
|
||||
int len = pstr[0];
|
||||
char* cstr = static_cast<char*>(NS_Alloc(len + 1));
|
||||
char* cstr = static_cast<char*>(moz_xmalloc(len + 1));
|
||||
if (cstr) {
|
||||
memmove(cstr, pstr + 1, len);
|
||||
cstr[len] = '\0';
|
||||
@ -540,14 +540,14 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary)
|
||||
|
||||
// Fill in the info struct based on the data in the BPSupportedMIMETypes struct
|
||||
int variantCount = info.fVariantCount;
|
||||
info.fMimeTypeArray = static_cast<char**>(NS_Alloc(variantCount * sizeof(char*)));
|
||||
info.fMimeTypeArray = static_cast<char**>(moz_xmalloc(variantCount * sizeof(char*)));
|
||||
if (!info.fMimeTypeArray)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
info.fExtensionArray = static_cast<char**>(NS_Alloc(variantCount * sizeof(char*)));
|
||||
info.fExtensionArray = static_cast<char**>(moz_xmalloc(variantCount * sizeof(char*)));
|
||||
if (!info.fExtensionArray)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if (mi.infoStrings) {
|
||||
info.fMimeDescriptionArray = static_cast<char**>(NS_Alloc(variantCount * sizeof(char*)));
|
||||
info.fMimeDescriptionArray = static_cast<char**>(moz_xmalloc(variantCount * sizeof(char*)));
|
||||
if (!info.fMimeDescriptionArray)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -572,20 +572,20 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary)
|
||||
|
||||
nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info)
|
||||
{
|
||||
NS_Free(info.fName);
|
||||
NS_Free(info.fDescription);
|
||||
free(info.fName);
|
||||
free(info.fDescription);
|
||||
int variantCount = info.fVariantCount;
|
||||
for (int i = 0; i < variantCount; i++) {
|
||||
NS_Free(info.fMimeTypeArray[i]);
|
||||
NS_Free(info.fExtensionArray[i]);
|
||||
NS_Free(info.fMimeDescriptionArray[i]);
|
||||
free(info.fMimeTypeArray[i]);
|
||||
free(info.fExtensionArray[i]);
|
||||
free(info.fMimeDescriptionArray[i]);
|
||||
}
|
||||
NS_Free(info.fMimeTypeArray);
|
||||
NS_Free(info.fMimeDescriptionArray);
|
||||
NS_Free(info.fExtensionArray);
|
||||
NS_Free(info.fFileName);
|
||||
NS_Free(info.fFullPath);
|
||||
NS_Free(info.fVersion);
|
||||
free(info.fMimeTypeArray);
|
||||
free(info.fMimeDescriptionArray);
|
||||
free(info.fExtensionArray);
|
||||
free(info.fFileName);
|
||||
free(info.fFullPath);
|
||||
free(info.fVersion);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -752,10 +752,10 @@ PluginModuleChild::AnswerNPP_GetSitesWithData(InfallibleTArray<nsCString>* aResu
|
||||
char** iterator = result;
|
||||
while (*iterator) {
|
||||
aResult->AppendElement(*iterator);
|
||||
NS_Free(*iterator);
|
||||
free(*iterator);
|
||||
++iterator;
|
||||
}
|
||||
NS_Free(result);
|
||||
free(result);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1330,7 +1330,7 @@ _memfree(void* aPtr)
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
// Only assert plugin thread here for consistency with in-process plugins.
|
||||
AssertPluginThread();
|
||||
NS_Free(aPtr);
|
||||
free(aPtr);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
@ -1399,7 +1399,7 @@ _memalloc(uint32_t aSize)
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
// Only assert plugin thread here for consistency with in-process plugins.
|
||||
AssertPluginThread();
|
||||
return NS_Alloc(aSize);
|
||||
return moz_xmalloc(aSize);
|
||||
}
|
||||
|
||||
// Deprecated entry points for the old Java plugin.
|
||||
|
@ -200,7 +200,7 @@ public:
|
||||
{
|
||||
// Notify mock EIT broadcasting.
|
||||
nsITVProgramData** programDataList =
|
||||
static_cast<nsITVProgramData **>(NS_Alloc(1 * sizeof(nsITVProgramData*)));
|
||||
static_cast<nsITVProgramData **>(moz_xmalloc(1 * sizeof(nsITVProgramData*)));
|
||||
programDataList[0] = new TVProgramData();
|
||||
programDataList[0]->SetEventId(NS_LITERAL_STRING("eventId"));
|
||||
programDataList[0]->SetTitle(NS_LITERAL_STRING("title"));
|
||||
|
@ -55,7 +55,7 @@ TVTunerData::GetSupportedSourceTypes(uint32_t* aCount,
|
||||
*aCount = mCount;
|
||||
|
||||
char** sourceTypes = (mCount > 0) ?
|
||||
static_cast<char **>(NS_Alloc(mCount * sizeof(char*))) :
|
||||
static_cast<char **>(moz_xmalloc(mCount * sizeof(char*))) :
|
||||
nullptr;
|
||||
for (uint32_t i = 0; i < mCount; i++) {
|
||||
sourceTypes[i] = NS_strdup(mSupportedSourceTypes[i]);
|
||||
@ -87,7 +87,7 @@ TVTunerData::SetSupportedSourceTypes(uint32_t aCount,
|
||||
mCount = aCount;
|
||||
|
||||
mSupportedSourceTypes = (mCount > 0) ?
|
||||
static_cast<char **>(NS_Alloc(mCount * sizeof(char*))) :
|
||||
static_cast<char **>(moz_xmalloc(mCount * sizeof(char*))) :
|
||||
nullptr;
|
||||
for (uint32_t i = 0; i < mCount; i++) {
|
||||
mSupportedSourceTypes[i] = NS_strdup(aSourceTypes[i]);
|
||||
@ -377,7 +377,7 @@ TVProgramData::GetAudioLanguages(uint32_t* aCount,
|
||||
*aCount = mAudioLanguageCount;
|
||||
|
||||
char** languages = (mAudioLanguageCount > 0) ?
|
||||
static_cast<char **>(NS_Alloc(mAudioLanguageCount * sizeof(char*))) :
|
||||
static_cast<char **>(moz_xmalloc(mAudioLanguageCount * sizeof(char*))) :
|
||||
nullptr;
|
||||
for (uint32_t i = 0; i < mAudioLanguageCount; i++) {
|
||||
languages[i] = NS_strdup(mAudioLanguages[i]);
|
||||
@ -402,7 +402,7 @@ TVProgramData::SetAudioLanguages(uint32_t aCount,
|
||||
mAudioLanguageCount = aCount;
|
||||
|
||||
mAudioLanguages = (mAudioLanguageCount > 0) ?
|
||||
static_cast<char **>(NS_Alloc(mAudioLanguageCount * sizeof(char*))) :
|
||||
static_cast<char **>(moz_xmalloc(mAudioLanguageCount * sizeof(char*))) :
|
||||
nullptr;
|
||||
for (uint32_t i = 0; i < mAudioLanguageCount; i++) {
|
||||
mAudioLanguages[i] = NS_strdup(aLanguages[i]);
|
||||
@ -418,7 +418,7 @@ TVProgramData::GetSubtitleLanguages(uint32_t* aCount,
|
||||
*aCount = mSubtitleLanguageCount;
|
||||
|
||||
char** languages = (mSubtitleLanguageCount > 0) ?
|
||||
static_cast<char **>(NS_Alloc(mSubtitleLanguageCount * sizeof(char*))) :
|
||||
static_cast<char **>(moz_xmalloc(mSubtitleLanguageCount * sizeof(char*))) :
|
||||
nullptr;
|
||||
for (uint32_t i = 0; i < mSubtitleLanguageCount; i++) {
|
||||
languages[i] = NS_strdup(mSubtitleLanguages[i]);
|
||||
@ -443,7 +443,7 @@ TVProgramData::SetSubtitleLanguages(uint32_t aCount,
|
||||
mSubtitleLanguageCount = aCount;
|
||||
|
||||
mSubtitleLanguages = (mSubtitleLanguageCount > 0) ?
|
||||
static_cast<char **>(NS_Alloc(mSubtitleLanguageCount * sizeof(char*))) :
|
||||
static_cast<char **>(moz_xmalloc(mSubtitleLanguageCount * sizeof(char*))) :
|
||||
nullptr;
|
||||
for (uint32_t i = 0; i < mSubtitleLanguageCount; i++) {
|
||||
mSubtitleLanguages[i] = NS_strdup(aLanguages[i]);
|
||||
|
@ -63,7 +63,7 @@ nsXBLProtoImplField::~nsXBLProtoImplField()
|
||||
MOZ_COUNT_DTOR(nsXBLProtoImplField);
|
||||
if (mFieldText)
|
||||
free(mFieldText);
|
||||
NS_Free(mName);
|
||||
free(mName);
|
||||
NS_CONTENT_DELETE_LIST_MEMBER(nsXBLProtoImplField, this, mNext);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "nsReadableUtils.h" // for ToNewUnicode
|
||||
#include "nsString.h" // for nsAutoString, nsString, etc
|
||||
#include "nsUnicharUtils.h" // for nsCaseInsensitiveStringComparator
|
||||
#include "nsXPCOM.h" // for NS_Free
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -75,7 +74,7 @@ ChangeStyleTxn::ValueIncludes(const nsAString &aValueList,
|
||||
}
|
||||
start = ++end;
|
||||
}
|
||||
NS_Free(value);
|
||||
free(value);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1632,7 +1632,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation(int32_t aSelectionType)
|
||||
rv = InsertAsPlaintextQuotation(stuffToPaste, true, 0);
|
||||
}
|
||||
}
|
||||
NS_Free(flav);
|
||||
free(flav);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -728,7 +728,7 @@ AssertParserServiceIsCorrect(nsIAtom* aTag, bool aIsBlock)
|
||||
assertmsg.Append(tagName);
|
||||
char* assertstr = ToNewCString(assertmsg);
|
||||
NS_ASSERTION(aIsBlock, assertstr);
|
||||
NS_Free(assertstr);
|
||||
free(assertstr);
|
||||
}
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
@ -127,7 +127,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertTextFromTransferable(nsITransferable *aTr
|
||||
rv = InsertTextAt(stuffToPaste, aDestinationNode, aDestOffset, aDoDeleteSelection);
|
||||
}
|
||||
}
|
||||
NS_Free(bestFlavor);
|
||||
free(bestFlavor);
|
||||
|
||||
// Try to scroll the selection into view if the paste/drop succeeded
|
||||
|
||||
|
@ -1390,7 +1390,7 @@ nsPlaintextEditor::PasteAsQuotation(int32_t aSelectionType)
|
||||
rv = InsertAsQuotation(stuffToPaste, 0);
|
||||
}
|
||||
}
|
||||
NS_Free(flav);
|
||||
free(flav);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -110,7 +110,7 @@ NS_IMETHODIMP nsTransactionList::GetData(int32_t aIndex,
|
||||
|
||||
nsCOMArray<nsISupports>& data = item->GetData();
|
||||
|
||||
nsISupports** ret = static_cast<nsISupports**>(NS_Alloc(data.Count() *
|
||||
nsISupports** ret = static_cast<nsISupports**>(moz_xmalloc(data.Count() *
|
||||
sizeof(nsISupports*)));
|
||||
|
||||
for (int32_t i = 0; i < data.Count(); i++) {
|
||||
|
@ -205,7 +205,7 @@ nsControllerCommandTable::GetSupportedCommands(uint32_t* aCount,
|
||||
char*** aCommands)
|
||||
{
|
||||
char** commands =
|
||||
static_cast<char **>(NS_Alloc(sizeof(char *) * mCommandsTable.Count()));
|
||||
static_cast<char **>(moz_xmalloc(sizeof(char *) * mCommandsTable.Count()));
|
||||
*aCount = mCommandsTable.Count();
|
||||
*aCommands = commands;
|
||||
|
||||
|
@ -322,7 +322,7 @@ NS_IMETHODIMP mozHunspell::GetDictionaryList(char16_t ***aDictionaries,
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
AppendNewStruct ans = {
|
||||
(char16_t**) NS_Alloc(sizeof(char16_t*) * mDictionaries.Count()),
|
||||
(char16_t**) moz_xmalloc(sizeof(char16_t*) * mDictionaries.Count()),
|
||||
0,
|
||||
false
|
||||
};
|
||||
@ -333,9 +333,9 @@ NS_IMETHODIMP mozHunspell::GetDictionaryList(char16_t ***aDictionaries,
|
||||
if (ans.failed) {
|
||||
while (ans.count) {
|
||||
--ans.count;
|
||||
NS_Free(ans.dics[ans.count]);
|
||||
free(ans.dics[ans.count]);
|
||||
}
|
||||
NS_Free(ans.dics);
|
||||
free(ans.dics);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -779,14 +779,14 @@ gfxDWriteFontList::MakePlatformFont(const nsAString& aFontName,
|
||||
nsAutoString uniqueName;
|
||||
rv = gfxFontUtils::MakeUniqueUserFontName(uniqueName);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_Free((void*)aFontData);
|
||||
free((void*)aFontData);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FallibleTArray<uint8_t> newFontData;
|
||||
|
||||
rv = gfxFontUtils::RenameFont(uniqueName, aFontData, aLength, &newFontData);
|
||||
NS_Free((void*)aFontData);
|
||||
free((void*)aFontData);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return nullptr;
|
||||
|
@ -266,12 +266,12 @@ FT2FontEntry::CreateFontEntry(const nsAString& aFontName,
|
||||
FT_New_Memory_Face(gfxToolkitPlatform::GetPlatform()->GetFTLibrary(),
|
||||
aFontData, aLength, 0, &face);
|
||||
if (error != FT_Err_Ok) {
|
||||
NS_Free((void*)aFontData);
|
||||
free((void*)aFontData);
|
||||
return nullptr;
|
||||
}
|
||||
if (FT_Err_Ok != FT_Select_Charmap(face, FT_ENCODING_UNICODE)) {
|
||||
FT_Done_Face(face);
|
||||
NS_Free((void*)aFontData);
|
||||
free((void*)aFontData);
|
||||
return nullptr;
|
||||
}
|
||||
// Create our FT2FontEntry, which inherits the name of the userfont entry
|
||||
@ -299,7 +299,7 @@ public:
|
||||
{
|
||||
FT_Done_Face(mFace);
|
||||
if (mFontData) {
|
||||
NS_Free((void*)mFontData);
|
||||
free((void*)mFontData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -762,13 +762,13 @@ gfxGDIFontList::MakePlatformFont(const nsAString& aFontName,
|
||||
const uint8_t* aFontData,
|
||||
uint32_t aLength)
|
||||
{
|
||||
// MakePlatformFont is responsible for deleting the font data with NS_Free
|
||||
// MakePlatformFont is responsible for deleting the font data with free
|
||||
// so we set up a stack object to ensure it is freed even if we take an
|
||||
// early exit
|
||||
struct FontDataDeleter {
|
||||
FontDataDeleter(const uint8_t* aFontData)
|
||||
: mFontData(aFontData) { }
|
||||
~FontDataDeleter() { NS_Free((void*)mFontData); }
|
||||
~FontDataDeleter() { free((void*)mFontData); }
|
||||
const uint8_t *mFontData;
|
||||
};
|
||||
FontDataDeleter autoDelete(aFontData);
|
||||
|
@ -971,7 +971,7 @@ gfxMacPlatformFontList::LookupLocalFont(const nsAString& aFontName,
|
||||
|
||||
static void ReleaseData(void *info, const void *data, size_t size)
|
||||
{
|
||||
NS_Free((void*)data);
|
||||
free((void*)data);
|
||||
}
|
||||
|
||||
gfxFontEntry*
|
||||
|
@ -473,7 +473,7 @@ protected:
|
||||
|
||||
// mFontData holds the data used to instantiate the FT_Face;
|
||||
// this has to persist until we are finished with the face,
|
||||
// then be released with NS_Free().
|
||||
// then be released with free().
|
||||
const uint8_t* mFontData;
|
||||
|
||||
FT_Face mFace;
|
||||
@ -522,7 +522,7 @@ gfxDownloadedFcFontEntry::~gfxDownloadedFcFontEntry()
|
||||
FcPatternDel(mPatterns[0], FC_FT_FACE);
|
||||
}
|
||||
FT_Done_Face(mFace);
|
||||
NS_Free((void*)mFontData);
|
||||
free((void*)mFontData);
|
||||
}
|
||||
|
||||
typedef FcPattern* (*QueryFaceFunction)(const FT_Face face,
|
||||
@ -1706,7 +1706,7 @@ gfxPangoFontGroup::NewFontEntry(const nsAString& aFontName,
|
||||
FT_Error error =
|
||||
FT_New_Memory_Face(GetFTLibrary(), aFontData, aLength, 0, &face);
|
||||
if (error != 0) {
|
||||
NS_Free((void*)aFontData);
|
||||
free((void*)aFontData);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -1333,7 +1333,7 @@ gfxPlatform::MakePlatformFont(const nsAString& aFontName,
|
||||
// using the data to instantiate the font, and taking responsibility
|
||||
// for freeing it when no longer required.
|
||||
if (aFontData) {
|
||||
NS_Free((void*)aFontData);
|
||||
free((void*)aFontData);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ public:
|
||||
bool aItalic) = 0;
|
||||
|
||||
// create a new platform font from downloaded data (@font-face)
|
||||
// this method is responsible to ensure aFontData is NS_Free()'d
|
||||
// this method is responsible to ensure aFontData is free()'d
|
||||
virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
|
||||
uint16_t aWeight,
|
||||
int16_t aStretch,
|
||||
|
@ -166,7 +166,7 @@ gfxPlatformMac::MakePlatformFont(const nsAString& aFontName,
|
||||
{
|
||||
// Ownership of aFontData is received here, and passed on to
|
||||
// gfxPlatformFontList::MakePlatformFont(), which must ensure the data
|
||||
// is released with NS_Free when no longer needed
|
||||
// is released with free when no longer needed
|
||||
return gfxPlatformFontList::PlatformFontList()->MakePlatformFont(aFontName,
|
||||
aWeight,
|
||||
aStretch,
|
||||
|
@ -47,15 +47,15 @@ class ExpandingMemoryStream : public ots::OTSStream {
|
||||
public:
|
||||
ExpandingMemoryStream(size_t initial, size_t limit)
|
||||
: mLength(initial), mLimit(limit), mOff(0) {
|
||||
mPtr = NS_Alloc(mLength);
|
||||
mPtr = moz_xmalloc(mLength);
|
||||
}
|
||||
|
||||
~ExpandingMemoryStream() {
|
||||
NS_Free(mPtr);
|
||||
free(mPtr);
|
||||
}
|
||||
|
||||
// return the buffer, and give up ownership of it
|
||||
// so the caller becomes responsible to call NS_Free
|
||||
// so the caller becomes responsible to call free
|
||||
// when finished with it
|
||||
void* forget() {
|
||||
void* p = mPtr;
|
||||
@ -76,7 +76,7 @@ public:
|
||||
if (newLength > mLimit) {
|
||||
newLength = mLimit;
|
||||
}
|
||||
mPtr = NS_Realloc(mPtr, newLength);
|
||||
mPtr = moz_xrealloc(mPtr, newLength);
|
||||
mLength = newLength;
|
||||
return WriteRaw(data, length);
|
||||
}
|
||||
|
@ -611,14 +611,14 @@ protected:
|
||||
// returns true if platform font creation sucessful (or local()
|
||||
// reference was next in line)
|
||||
// Ownership of aFontData is passed in here; the font set must
|
||||
// ensure that it is eventually deleted with NS_Free().
|
||||
// ensure that it is eventually deleted with free().
|
||||
bool FontDataDownloadComplete(const uint8_t* aFontData, uint32_t aLength,
|
||||
nsresult aDownloadStatus);
|
||||
|
||||
// helper method for creating a platform font
|
||||
// returns true if platform font creation successful
|
||||
// Ownership of aFontData is passed in here; the font must
|
||||
// ensure that it is eventually deleted with NS_Free().
|
||||
// ensure that it is eventually deleted with free().
|
||||
bool LoadPlatformFont(const uint8_t* aFontData, uint32_t& aLength);
|
||||
|
||||
// store metadata and src details for current src into aFontEntry
|
||||
|
@ -72,7 +72,7 @@ moz_icon_to_channel(nsIURI* aURI, const nsACString& aFileExt,
|
||||
// then the ARGB pixel values with pre-multiplied Alpha
|
||||
const int channels = 4;
|
||||
long int buf_size = 2 + channels * height * width;
|
||||
uint8_t* const buf = (uint8_t*)NS_Alloc(buf_size);
|
||||
uint8_t* const buf = (uint8_t*)moz_xmalloc(buf_size);
|
||||
NS_ENSURE_TRUE(buf, NS_ERROR_OUT_OF_MEMORY);
|
||||
uint8_t* out = buf;
|
||||
|
||||
|
@ -47,7 +47,7 @@ moz_gdk_pixbuf_to_channel(GdkPixbuf* aPixbuf, nsIURI* aURI,
|
||||
|
||||
const int n_channels = 4;
|
||||
gsize buf_size = 2 + n_channels * height * width;
|
||||
uint8_t* const buf = (uint8_t*)NS_Alloc(buf_size);
|
||||
uint8_t* const buf = (uint8_t*)moz_xmalloc(buf_size);
|
||||
NS_ENSURE_TRUE(buf, NS_ERROR_OUT_OF_MEMORY);
|
||||
uint8_t* out = buf;
|
||||
|
||||
@ -89,7 +89,7 @@ moz_gdk_pixbuf_to_channel(GdkPixbuf* aPixbuf, nsIURI* aURI,
|
||||
|
||||
// Prevent the leaking of buf
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
NS_Free(buf);
|
||||
free(buf);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ moz_qicon_to_channel(QImage* image, nsIURI* aURI,
|
||||
|
||||
const int n_channels = 4;
|
||||
long int buf_size = 2 + n_channels * height * width;
|
||||
uint8_t* const buf = (uint8_t*)NS_Alloc(buf_size);
|
||||
uint8_t* const buf = (uint8_t*)moz_xmalloc(buf_size);
|
||||
NS_ENSURE_TRUE(buf, NS_ERROR_OUT_OF_MEMORY);
|
||||
uint8_t* out = buf;
|
||||
|
||||
|
@ -72,7 +72,7 @@ NS_IMETHODIMP nsTextToSubURI::ConvertAndEscape(
|
||||
int32_t outlen = 0;
|
||||
if (NS_SUCCEEDED(rv = encoder->GetMaxLength(text, ulen, &outlen))) {
|
||||
if (outlen >= 256) {
|
||||
pBuf = (char*)NS_Alloc(outlen+1);
|
||||
pBuf = (char*)moz_xmalloc(outlen+1);
|
||||
}
|
||||
if (nullptr == pBuf) {
|
||||
outlen = 255;
|
||||
@ -95,7 +95,7 @@ NS_IMETHODIMP nsTextToSubURI::ConvertAndEscape(
|
||||
}
|
||||
}
|
||||
if (pBuf != buf) {
|
||||
NS_Free(pBuf);
|
||||
free(pBuf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ NS_IMETHODIMP nsTextToSubURI::UnEscapeAndConvert(
|
||||
int32_t len = strlen(unescaped);
|
||||
int32_t outlen = 0;
|
||||
if (NS_SUCCEEDED(rv = decoder->GetMaxLength(unescaped, len, &outlen))) {
|
||||
pBuf = (char16_t *) NS_Alloc((outlen+1)*sizeof(char16_t));
|
||||
pBuf = (char16_t *) moz_xmalloc((outlen+1)*sizeof(char16_t));
|
||||
if (nullptr == pBuf) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
} else {
|
||||
@ -146,11 +146,11 @@ NS_IMETHODIMP nsTextToSubURI::UnEscapeAndConvert(
|
||||
pBuf[outlen] = 0;
|
||||
*_retval = pBuf;
|
||||
} else {
|
||||
NS_Free(pBuf);
|
||||
free(pBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_Free(unescaped);
|
||||
free(unescaped);
|
||||
|
||||
return rv;
|
||||
}
|
||||
@ -203,7 +203,7 @@ nsresult nsTextToSubURI::convertURItoUnicode(const nsAFlatCString &aCharset,
|
||||
nsresult rv = unicodeDecoder->GetMaxLength(aURI.get(), srcLen, &dstLen);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
char16_t *ustr = (char16_t *) NS_Alloc(dstLen * sizeof(char16_t));
|
||||
char16_t *ustr = (char16_t *) moz_xmalloc(dstLen * sizeof(char16_t));
|
||||
NS_ENSURE_TRUE(ustr, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
rv = unicodeDecoder->Convert(aURI.get(), &srcLen, ustr, &dstLen);
|
||||
@ -211,7 +211,7 @@ nsresult nsTextToSubURI::convertURItoUnicode(const nsAFlatCString &aCharset,
|
||||
if (NS_SUCCEEDED(rv))
|
||||
_retval.Assign(ustr, dstLen);
|
||||
|
||||
NS_Free(ustr);
|
||||
free(ustr);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ class mozJSComponentLoader : public mozilla::ModuleLoader,
|
||||
}
|
||||
|
||||
if (location)
|
||||
NS_Free(location);
|
||||
free(location);
|
||||
|
||||
obj = nullptr;
|
||||
thisObjectKey = nullptr;
|
||||
|
@ -33,9 +33,9 @@ nsJSID::nsJSID()
|
||||
nsJSID::~nsJSID()
|
||||
{
|
||||
if (mNumber && mNumber != gNoString)
|
||||
NS_Free(mNumber);
|
||||
free(mNumber);
|
||||
if (mName && mName != gNoString)
|
||||
NS_Free(mName);
|
||||
free(mName);
|
||||
}
|
||||
|
||||
void nsJSID::Reset()
|
||||
@ -43,9 +43,9 @@ void nsJSID::Reset()
|
||||
mID = GetInvalidIID();
|
||||
|
||||
if (mNumber && mNumber != gNoString)
|
||||
NS_Free(mNumber);
|
||||
free(mNumber);
|
||||
if (mName && mName != gNoString)
|
||||
NS_Free(mName);
|
||||
free(mName);
|
||||
|
||||
mNumber = mName = nullptr;
|
||||
}
|
||||
|
@ -624,7 +624,7 @@ nsXPCWrappedJS::DebugDump(int16_t depth)
|
||||
char * iid = GetClass()->GetIID().ToString();
|
||||
XPC_LOG_ALWAYS(("IID number is %s", iid ? iid : "invalid"));
|
||||
if (iid)
|
||||
NS_Free(iid);
|
||||
free(iid);
|
||||
XPC_LOG_ALWAYS(("nsXPCWrappedJSClass @ %x", mClass.get()));
|
||||
|
||||
if (!IsRootWrapper())
|
||||
|
@ -1481,7 +1481,7 @@ nsXPCWrappedJSClass::DebugDump(int16_t depth)
|
||||
char * iid = mIID.ToString();
|
||||
XPC_LOG_ALWAYS(("IID number is %s", iid ? iid : "invalid"));
|
||||
if (iid)
|
||||
NS_Free(iid);
|
||||
free(iid);
|
||||
XPC_LOG_ALWAYS(("InterfaceInfo @ %x", mInfo.get()));
|
||||
uint16_t methodCount = 0;
|
||||
if (depth) {
|
||||
|
@ -49,15 +49,15 @@ nsXPCTestParams::~nsXPCTestParams()
|
||||
\
|
||||
/* Copy b into rv. */ \
|
||||
*rvLength = *bLength; \
|
||||
*rv = static_cast<type*>(NS_Alloc(elemSize * (*bLength + padding))); \
|
||||
*rv = static_cast<type*>(moz_xmalloc(elemSize * (*bLength + padding))); \
|
||||
if (!*rv) \
|
||||
return NS_ERROR_OUT_OF_MEMORY; \
|
||||
memcpy(*rv, *b, elemSize * (*bLength + padding)); \
|
||||
\
|
||||
/* Copy a into b. */ \
|
||||
*bLength = aLength; \
|
||||
NS_Free(*b); \
|
||||
*b = static_cast<type*>(NS_Alloc(elemSize * (aLength + padding))); \
|
||||
free(*b); \
|
||||
*b = static_cast<type*>(moz_xmalloc(elemSize * (aLength + padding))); \
|
||||
if (!*b) \
|
||||
return NS_ERROR_OUT_OF_MEMORY; \
|
||||
memcpy(*b, a, elemSize * (aLength + padding)); \
|
||||
@ -146,7 +146,7 @@ NS_IMETHODIMP nsXPCTestParams::TestString(const char * a, char * *b, char * *_re
|
||||
|
||||
// XPCOM ownership rules dictate that overwritten inout params must be callee-freed.
|
||||
// See https://developer.mozilla.org/en/XPIDL
|
||||
NS_Free(const_cast<char*>(bprime.get()));
|
||||
free(const_cast<char*>(bprime.get()));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -167,7 +167,7 @@ NS_IMETHODIMP nsXPCTestParams::TestWstring(const char16_t * a, char16_t * *b, ch
|
||||
|
||||
// XPCOM ownership rules dictate that overwritten inout params must be callee-freed.
|
||||
// See https://developer.mozilla.org/en/XPIDL
|
||||
NS_Free((void*)bprime.get());
|
||||
free((void*)bprime.get());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -297,7 +297,7 @@ NS_IMETHODIMP nsXPCTestParams::TestInterfaceIs(const nsIID* aIID, void* a,
|
||||
|
||||
// rvIID is out-only, so nobody allocated an IID buffer for us. Do that now,
|
||||
// and store b's IID in the new buffer.
|
||||
*rvIID = static_cast<nsIID*>(NS_Alloc(sizeof(nsID)));
|
||||
*rvIID = static_cast<nsIID*>(moz_xmalloc(sizeof(nsID)));
|
||||
if (!*rvIID)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
**rvIID = **bIID;
|
||||
@ -328,7 +328,7 @@ NS_IMETHODIMP nsXPCTestParams::TestInterfaceIsArray(uint32_t aLength, const nsII
|
||||
{
|
||||
// Transfer the IIDs. See the comments in TestInterfaceIs (above) for an
|
||||
// explanation of what we're doing.
|
||||
*rvIID = static_cast<nsIID*>(NS_Alloc(sizeof(nsID)));
|
||||
*rvIID = static_cast<nsIID*>(moz_xmalloc(sizeof(nsID)));
|
||||
if (!*rvIID)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
**rvIID = **bIID;
|
||||
|
@ -10413,7 +10413,7 @@ int ReflowCountMgr::RemoveItems(PLHashEntry *he, int i, void *arg)
|
||||
char *str = (char *)he->key;
|
||||
ReflowCounter * counter = (ReflowCounter *)he->value;
|
||||
delete counter;
|
||||
NS_Free(str);
|
||||
free(str);
|
||||
|
||||
return HT_ENUMERATE_REMOVE;
|
||||
}
|
||||
@ -10424,7 +10424,7 @@ int ReflowCountMgr::RemoveIndiItems(PLHashEntry *he, int i, void *arg)
|
||||
char *str = (char *)he->key;
|
||||
IndiReflowCounter * counter = (IndiReflowCounter *)he->value;
|
||||
delete counter;
|
||||
NS_Free(str);
|
||||
free(str);
|
||||
|
||||
return HT_ENUMERATE_REMOVE;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ inDOMUtils::GetAllStyleSheets(nsIDOMDocument *aDocument, uint32_t *aLength,
|
||||
sheets.AppendElement(document->GetStyleSheetAt(i));
|
||||
}
|
||||
|
||||
nsISupports** ret = static_cast<nsISupports**>(NS_Alloc(sheets.Count() *
|
||||
nsISupports** ret = static_cast<nsISupports**>(moz_xmalloc(sheets.Count() *
|
||||
sizeof(nsISupports*)));
|
||||
|
||||
for (int32_t i = 0; i < sheets.Count(); i++) {
|
||||
@ -773,7 +773,7 @@ inDOMUtils::GetCSSValuesForProperty(const nsAString& aProperty,
|
||||
|
||||
*aLength = array.Length();
|
||||
char16_t** ret =
|
||||
static_cast<char16_t**>(NS_Alloc(*aLength * sizeof(char16_t*)));
|
||||
static_cast<char16_t**>(moz_xmalloc(*aLength * sizeof(char16_t*)));
|
||||
for (uint32_t i = 0; i < *aLength; ++i) {
|
||||
ret[i] = ToNewUnicode(array[i]);
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ nsPrintData::~nsPrintData()
|
||||
delete mPrintObject;
|
||||
|
||||
if (mBrandName) {
|
||||
NS_Free(mBrandName);
|
||||
free(mBrandName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ FontFace::~FontFace()
|
||||
}
|
||||
|
||||
if (mSourceBuffer) {
|
||||
NS_Free(mSourceBuffer);
|
||||
free(mSourceBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1262,7 +1262,7 @@ FontFaceSet::SyncLoadFontData(gfxUserFontEntry* aFontToLoad,
|
||||
aBufferLength = static_cast<uint32_t>(bufferLength64);
|
||||
|
||||
// read all the decoded data
|
||||
aBuffer = static_cast<uint8_t*> (NS_Alloc(sizeof(uint8_t) * aBufferLength));
|
||||
aBuffer = static_cast<uint8_t*> (moz_xmalloc(sizeof(uint8_t) * aBufferLength));
|
||||
if (!aBuffer) {
|
||||
aBufferLength = 0;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -1289,7 +1289,7 @@ FontFaceSet::SyncLoadFontData(gfxUserFontEntry* aFontToLoad,
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_Free(aBuffer);
|
||||
free(aBuffer);
|
||||
aBuffer = nullptr;
|
||||
aBufferLength = 0;
|
||||
return rv;
|
||||
|
@ -210,7 +210,7 @@ nsPseudoClassList::~nsPseudoClassList(void)
|
||||
if (nsCSSPseudoClasses::HasSelectorListArg(mType)) {
|
||||
delete u.mSelectors;
|
||||
} else if (u.mMemory) {
|
||||
NS_Free(u.mMemory);
|
||||
free(u.mMemory);
|
||||
}
|
||||
NS_CSS_DELETE_LIST_MEMBER(nsPseudoClassList, this, mNext);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
// (if nsCSSPseudoClasses::HasNthPairArg(mType))
|
||||
// d. a selector list, which means mSelectors is non-null
|
||||
// (if nsCSSPseudoClasses::HasSelectorListArg(mType))
|
||||
void* mMemory; // mString and mNumbers use NS_Alloc/NS_Free
|
||||
void* mMemory; // mString and mNumbers use moz_xmalloc/free
|
||||
char16_t* mString;
|
||||
int32_t* mNumbers;
|
||||
nsCSSSelectorList* mSelectors;
|
||||
|
@ -1886,7 +1886,7 @@ nsStyleImage::SetNull()
|
||||
else if (mType == eStyleImageType_Image)
|
||||
NS_RELEASE(mImage);
|
||||
else if (mType == eStyleImageType_Element)
|
||||
NS_Free(mElementId);
|
||||
free(mElementId);
|
||||
|
||||
mType = eStyleImageType_Null;
|
||||
mCropRect = nullptr;
|
||||
@ -2984,7 +2984,7 @@ nsStyleContentData::~nsStyleContentData()
|
||||
mType == eStyleContentType_Counters) {
|
||||
mContent.mCounters->Release();
|
||||
} else if (mContent.mString) {
|
||||
NS_Free(mContent.mString);
|
||||
free(mContent.mString);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,6 @@ allocatorFns = [
|
||||
'memalign',
|
||||
'operator new(',
|
||||
'operator new[](',
|
||||
'NS_Alloc',
|
||||
'NS_Realloc',
|
||||
'g_slice_alloc',
|
||||
# This one necessary to fully filter some sequences of allocation functions
|
||||
# that happen in practice. Note that ??? entries that follow non-allocation
|
||||
|
@ -978,7 +978,7 @@ Preferences::WritePrefFile(nsIFile* aFile)
|
||||
if (*walker) {
|
||||
outStream->Write(*walker, strlen(*walker), &writeAmount);
|
||||
outStream->Write(NS_LINEBREAK, NS_LINEBREAK_LEN, &writeAmount);
|
||||
NS_Free(*walker);
|
||||
free(*walker);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -889,7 +889,7 @@ nsStandardURL::AppendToSubstring(uint32_t pos,
|
||||
if (UINT32_MAX - ((uint32_t)len + 1) < tailLen)
|
||||
return nullptr;
|
||||
|
||||
char *result = (char *) NS_Alloc(len + tailLen + 1);
|
||||
char *result = (char *) moz_xmalloc(len + tailLen + 1);
|
||||
if (result) {
|
||||
memcpy(result, mSpec.get() + pos, len);
|
||||
memcpy(result + len, tail, tailLen);
|
||||
|
2
netwerk/cache/nsDiskCacheDeviceSQL.cpp
vendored
2
netwerk/cache/nsDiskCacheDeviceSQL.cpp
vendored
@ -2286,7 +2286,7 @@ nsOfflineCacheDevice::RunSimpleQuery(mozIStorageStatement * statement,
|
||||
}
|
||||
|
||||
*count = valArray.Length();
|
||||
char **ret = static_cast<char **>(NS_Alloc(*count * sizeof(char*)));
|
||||
char **ret = static_cast<char **>(moz_xmalloc(*count * sizeof(char*)));
|
||||
if (!ret) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
for (uint32_t i = 0; i < *count; i++) {
|
||||
|
@ -2054,7 +2054,7 @@ WebSocketChannel::PrimeNewOutgoingMessage()
|
||||
return;
|
||||
}
|
||||
mask = * reinterpret_cast<uint32_t *>(buffer);
|
||||
NS_Free(buffer);
|
||||
free(buffer);
|
||||
} while (!mask);
|
||||
NetworkEndian::writeUint32(payload - sizeof(uint32_t), mask);
|
||||
|
||||
@ -2492,7 +2492,7 @@ WebSocketChannel::SetupRequest()
|
||||
rv = mRandomGenerator->GenerateRandomBytes(16, &secKey);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
char* b64 = PL_Base64Encode((const char *)secKey, 16, nullptr);
|
||||
NS_Free(secKey);
|
||||
free(secKey);
|
||||
if (!b64)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
secKeyString.Assign(b64);
|
||||
|
@ -255,7 +255,7 @@ nsDirIndexParser::ParseData(nsIDirIndex *aIdx, char* aDataStr) {
|
||||
aIdx->SetDescription(result);
|
||||
success = true;
|
||||
}
|
||||
NS_Free(result);
|
||||
free(result);
|
||||
} else {
|
||||
NS_WARNING("UnEscapeAndConvert error");
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ nsParserUtils::ParseFragment(const nsAString& aFragment,
|
||||
char* escapedSpec = nsEscapeHTML(spec.get());
|
||||
if (escapedSpec)
|
||||
base += escapedSpec;
|
||||
NS_Free(escapedSpec);
|
||||
free(escapedSpec);
|
||||
base.Append('"');
|
||||
tagStack.AppendElement(NS_ConvertUTF8toUTF16(base));
|
||||
} else {
|
||||
|
@ -908,7 +908,7 @@ InMemoryDataSource::LogOperation(const char* aOperation,
|
||||
PR_LogPrint
|
||||
(" -->(\"%s\")\n", valueCStr);
|
||||
|
||||
NS_Free(valueCStr);
|
||||
free(valueCStr);
|
||||
}
|
||||
else {
|
||||
PR_LogPrint
|
||||
|
@ -455,7 +455,7 @@ RDFContentSinkImpl::HandleEndElement(const char16_t *aName)
|
||||
("rdfxml: extra close tag '%s' at line %d",
|
||||
tagCStr, 0/*XXX fix me */);
|
||||
|
||||
NS_Free(tagCStr);
|
||||
free(tagCStr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1012,7 +1012,7 @@ FileSystemDataSource::GetFolderList(nsIRDFResource *source, bool allowHidden,
|
||||
continue;
|
||||
|
||||
nsAutoCString leaf(escLeafStr);
|
||||
NS_Free(escLeafStr);
|
||||
free(escLeafStr);
|
||||
escLeafStr = nullptr;
|
||||
|
||||
// using nsEscape() [above] doesn't escape slashes, so do that by hand
|
||||
|
@ -856,7 +856,7 @@ void PK11PasswordPromptRunnable::RunOnTargetThread()
|
||||
|
||||
if (NS_SUCCEEDED(rv) && value) {
|
||||
mResult = ToNewUTF8String(nsDependentString(password));
|
||||
NS_Free(password);
|
||||
free(password);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ nsRandomGenerator::GenerateRandomBytes(uint32_t aLength,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
uint8_t* buf = reinterpret_cast<uint8_t*>(NS_Alloc(aLength));
|
||||
uint8_t* buf = reinterpret_cast<uint8_t*>(moz_xmalloc(aLength));
|
||||
if (!buf) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -38,7 +38,7 @@ nsRandomGenerator::GenerateRandomBytes(uint32_t aLength,
|
||||
SECStatus srv = PK11_GenerateRandomOnSlot(slot, buf, aLength);
|
||||
|
||||
if (srv != SECSuccess) {
|
||||
NS_Free(buf);
|
||||
free(buf);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ interface mozIStorageBindingParams : nsISupports {
|
||||
void bindUTF8StringAsBlobByName(in AUTF8String aName, in AUTF8String aValue);
|
||||
|
||||
// The function adopts the storage for the provided blob. After calling
|
||||
// this function, mozStorage will ensure that NS_Free is called on the
|
||||
// this function, mozStorage will ensure that free is called on the
|
||||
// underlying pointer.
|
||||
[noscript]
|
||||
void bindAdoptedBlobByName(in AUTF8String aName,
|
||||
@ -77,7 +77,7 @@ interface mozIStorageBindingParams : nsISupports {
|
||||
void bindUTF8StringAsBlobByIndex(in unsigned long aIndex, in AUTF8String aValue);
|
||||
|
||||
// The function adopts the storage for the provided blob. After calling
|
||||
// this function, mozStorage will ensure that NS_Free is called on the
|
||||
// this function, mozStorage will ensure that free is called on the
|
||||
// underlying pointer.
|
||||
[noscript]
|
||||
void bindAdoptedBlobByIndex(in unsigned long aIndex,
|
||||
|
@ -281,7 +281,7 @@ struct variant_storage_traits<uint8_t[], true>
|
||||
static inline void destroy(StorageType &aData)
|
||||
{
|
||||
if (aData.first) {
|
||||
NS_Free(aData.first);
|
||||
free(aData.first);
|
||||
aData.first = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ sqlite3_T_blob(BindingColumnData aData,
|
||||
int aSize)
|
||||
{
|
||||
return ::sqlite3_bind_blob(aData.stmt, aData.column + 1, aBlob, aSize,
|
||||
NS_Free);
|
||||
free);
|
||||
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ sqlite3_T_blob(sqlite3_context *aCtx,
|
||||
const void *aData,
|
||||
int aSize)
|
||||
{
|
||||
::sqlite3_result_blob(aCtx, aData, aSize, NS_Free);
|
||||
::sqlite3_result_blob(aCtx, aData, aSize, free);
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ variantToSQLiteT(T aObj,
|
||||
if (type != nsIDataType::VTYPE_UINT8) {
|
||||
// Technically this could leak with certain data types, but somebody was
|
||||
// being stupid passing us this anyway.
|
||||
NS_Free(data);
|
||||
free(data);
|
||||
return SQLITE_MISMATCH;
|
||||
}
|
||||
|
||||
|
@ -489,7 +489,7 @@ LogConsoleMessage(const char16_t* fmt, ...)
|
||||
if (cs)
|
||||
cs->LogStringMessage(msg);
|
||||
|
||||
NS_Free(msg);
|
||||
free(msg);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -293,7 +293,7 @@ nsFileView::~nsFileView()
|
||||
{
|
||||
uint32_t count = mCurrentFilters.Length();
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
NS_Free(mCurrentFilters[i]);
|
||||
free(mCurrentFilters[i]);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -469,7 +469,7 @@ nsFileView::SetFilter(const nsAString& aFilterString)
|
||||
{
|
||||
uint32_t filterCount = mCurrentFilters.Length();
|
||||
for (uint32_t i = 0; i < filterCount; ++i)
|
||||
NS_Free(mCurrentFilters[i]);
|
||||
free(mCurrentFilters[i]);
|
||||
mCurrentFilters.Clear();
|
||||
|
||||
nsAString::const_iterator start, iter, end;
|
||||
@ -498,7 +498,7 @@ nsFileView::SetFilter(const nsAString& aFilterString)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (!mCurrentFilters.AppendElement(filter)) {
|
||||
NS_Free(filter);
|
||||
free(filter);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ nsParentalControlsService::RequestURIOverrides(nsIArray *aTargets, nsIInterfaceR
|
||||
|
||||
// Free up the allocated strings in our array
|
||||
for (idx = 0; idx < uriIdx; idx++)
|
||||
NS_Free((void*)arrUrls[idx]);
|
||||
free((void*)arrUrls[idx]);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ public:
|
||||
"Failed to write all of our data out to the stream!");
|
||||
|
||||
// Free our favicon array.
|
||||
NS_Free(favicon);
|
||||
free(favicon);
|
||||
|
||||
// Handle an error to write if it occurred, but only after we've freed our
|
||||
// favicon.
|
||||
|
@ -1148,7 +1148,7 @@ NS_IMETHODIMP nsNavHistoryQuery::GetTags(nsIVariant **aTags)
|
||||
else {
|
||||
// Note: The resulting nsIVariant dupes both the array and its elements.
|
||||
const char16_t **array = reinterpret_cast<const char16_t **>
|
||||
(NS_Alloc(arrayLen * sizeof(char16_t *)));
|
||||
(moz_xmalloc(arrayLen * sizeof(char16_t *)));
|
||||
NS_ENSURE_TRUE(array, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
for (uint32_t i = 0; i < arrayLen; ++i) {
|
||||
@ -1159,7 +1159,7 @@ NS_IMETHODIMP nsNavHistoryQuery::GetTags(nsIVariant **aTags)
|
||||
nullptr,
|
||||
arrayLen,
|
||||
reinterpret_cast<void *>(array));
|
||||
NS_Free(array);
|
||||
free(array);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -1202,7 +1202,7 @@ NS_IMETHODIMP nsNavHistoryQuery::SetTags(nsIVariant *aTags)
|
||||
char **charArray = reinterpret_cast<char **>(array);
|
||||
for (uint32_t i = 0; i < arrayLen; ++i) {
|
||||
if (charArray[i])
|
||||
NS_Free(charArray[i]);
|
||||
free(charArray[i]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1217,7 +1217,7 @@ NS_IMETHODIMP nsNavHistoryQuery::SetTags(nsIVariant *aTags)
|
||||
break;
|
||||
// The other types are primitives that do not need to be freed.
|
||||
}
|
||||
NS_Free(array);
|
||||
free(array);
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
@ -1229,7 +1229,7 @@ NS_IMETHODIMP nsNavHistoryQuery::SetTags(nsIVariant *aTags)
|
||||
|
||||
// Don't allow nulls.
|
||||
if (!tags[i]) {
|
||||
NS_Free(tags);
|
||||
free(tags);
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
@ -1239,14 +1239,14 @@ NS_IMETHODIMP nsNavHistoryQuery::SetTags(nsIVariant *aTags)
|
||||
// fancy; the SQL that's built from the tags relies on no dupes.
|
||||
if (!mTags.Contains(tag)) {
|
||||
if (!mTags.AppendElement(tag)) {
|
||||
NS_Free(tags[i]);
|
||||
NS_Free(tags);
|
||||
free(tags[i]);
|
||||
free(tags);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
NS_Free(tags[i]);
|
||||
free(tags[i]);
|
||||
}
|
||||
NS_Free(tags);
|
||||
free(tags);
|
||||
|
||||
mTags.Sort();
|
||||
|
||||
@ -1310,7 +1310,7 @@ NS_IMETHODIMP nsNavHistoryQuery::GetTransitions(uint32_t* aCount,
|
||||
uint32_t* transitions = nullptr;
|
||||
if (count > 0) {
|
||||
transitions = reinterpret_cast<uint32_t*>
|
||||
(NS_Alloc(count * sizeof(uint32_t)));
|
||||
(moz_xmalloc(count * sizeof(uint32_t)));
|
||||
NS_ENSURE_TRUE(transitions, NS_ERROR_OUT_OF_MEMORY);
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
transitions[i] = mTransitions[i];
|
||||
|
@ -17,12 +17,12 @@ void GetObjCExceptionInfo(void* inException, nsACString& outString)
|
||||
unsigned int nameLength = [name length];
|
||||
unsigned int reasonLength = [reason length];
|
||||
|
||||
unichar* nameBuffer = (unichar*)NS_Alloc(sizeof(unichar) * (nameLength + 1));
|
||||
unichar* nameBuffer = (unichar*)moz_xmalloc(sizeof(unichar) * (nameLength + 1));
|
||||
if (!nameBuffer)
|
||||
return;
|
||||
unichar* reasonBuffer = (unichar*)NS_Alloc(sizeof(unichar) * (reasonLength + 1));
|
||||
unichar* reasonBuffer = (unichar*)moz_xmalloc(sizeof(unichar) * (reasonLength + 1));
|
||||
if (!reasonBuffer) {
|
||||
NS_Free(nameBuffer);
|
||||
free(nameBuffer);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -36,6 +36,6 @@ void GetObjCExceptionInfo(void* inException, nsACString& outString)
|
||||
outString.AppendLiteral(": ");
|
||||
AppendUTF16toUTF8(reinterpret_cast<const char16_t*>(reasonBuffer), outString);
|
||||
|
||||
NS_Free(nameBuffer);
|
||||
NS_Free(reasonBuffer);
|
||||
free(nameBuffer);
|
||||
free(reasonBuffer);
|
||||
}
|
||||
|
@ -1645,22 +1645,22 @@ nsresult UnsetExceptionHandler()
|
||||
lastRunCrashID = nullptr;
|
||||
|
||||
if (pendingDirectory) {
|
||||
NS_Free(pendingDirectory);
|
||||
free(pendingDirectory);
|
||||
pendingDirectory = nullptr;
|
||||
}
|
||||
|
||||
if (crashReporterPath) {
|
||||
NS_Free(crashReporterPath);
|
||||
free(crashReporterPath);
|
||||
crashReporterPath = nullptr;
|
||||
}
|
||||
|
||||
if (eventsDirectory) {
|
||||
NS_Free(eventsDirectory);
|
||||
free(eventsDirectory);
|
||||
eventsDirectory = nullptr;
|
||||
}
|
||||
|
||||
if (memoryReportPath) {
|
||||
NS_Free(memoryReportPath);
|
||||
free(memoryReportPath);
|
||||
memoryReportPath = nullptr;
|
||||
}
|
||||
|
||||
@ -2245,7 +2245,7 @@ SetCrashEventsDir(nsIFile* aDir)
|
||||
}
|
||||
|
||||
if (eventsDirectory) {
|
||||
NS_Free(eventsDirectory);
|
||||
free(eventsDirectory);
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
@ -2273,7 +2273,7 @@ SetCrashEventsDir(nsIFile* aDir)
|
||||
PR_SetEnv(eventsEnv);
|
||||
|
||||
if (oldEventsEnv) {
|
||||
NS_Free(oldEventsEnv);
|
||||
free(oldEventsEnv);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -2044,7 +2044,7 @@ ShowProfileManager(nsIToolkitProfileService* aProfileSvc,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
CopyUTF16toUTF8(profileNamePtr, profileName);
|
||||
NS_Free(profileNamePtr);
|
||||
free(profileNamePtr);
|
||||
|
||||
lock->Unlock();
|
||||
}
|
||||
|
@ -91,5 +91,5 @@ WriteConsoleLog()
|
||||
}
|
||||
|
||||
PR_Close(file);
|
||||
NS_Free(messages);
|
||||
free(messages);
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ nsExternalSharingAppService::GetSharingApps(const nsAString & aMIMEType,
|
||||
nullptr, sendAction);
|
||||
array->GetLength(aLen);
|
||||
*aHandlers =
|
||||
static_cast<nsISharingHandlerApp**>(NS_Alloc(sizeof(nsISharingHandlerApp*)
|
||||
* *aLen));
|
||||
static_cast<nsISharingHandlerApp**>(moz_xmalloc(sizeof(nsISharingHandlerApp*)
|
||||
* *aLen));
|
||||
for (uint32_t i = 0; i < *aLen; i++) {
|
||||
rv = array->QueryElementAt(i, NS_GET_IID(nsISharingHandlerApp),
|
||||
(void**)(*aHandlers + i));
|
||||
|
@ -1405,7 +1405,7 @@ nsresult nsExternalAppHandler::SetUpTempFile(nsIChannel * aChannel)
|
||||
nsAutoCString tempLeafName;
|
||||
nsDependentCSubstring randomData(reinterpret_cast<const char*>(buffer), requiredBytesLength);
|
||||
rv = Base64Encode(randomData, tempLeafName);
|
||||
NS_Free(buffer);
|
||||
free(buffer);
|
||||
buffer = nullptr;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -61,9 +61,9 @@ nsPrintDialogServiceX::Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings,
|
||||
CFRelease(cfTitleString);
|
||||
}
|
||||
for (int32_t i = titleCount - 1; i >= 0; i--) {
|
||||
NS_Free(docTitles[i]);
|
||||
free(docTitles[i]);
|
||||
}
|
||||
NS_Free(docTitles);
|
||||
free(docTitles);
|
||||
docTitles = NULL;
|
||||
titleCount = 0;
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ nsFilePicker::nsFilePicker() :
|
||||
nsFilePicker::~nsFilePicker()
|
||||
{
|
||||
if (mLastUsedUnicodeDirectory) {
|
||||
NS_Free(mLastUsedUnicodeDirectory);
|
||||
free(mLastUsedUnicodeDirectory);
|
||||
mLastUsedUnicodeDirectory = nullptr;
|
||||
}
|
||||
CoUninitialize();
|
||||
@ -1276,7 +1276,7 @@ nsFilePicker::RememberLastUsedDirectory()
|
||||
}
|
||||
|
||||
if (mLastUsedUnicodeDirectory) {
|
||||
NS_Free(mLastUsedUnicodeDirectory);
|
||||
free(mLastUsedUnicodeDirectory);
|
||||
mLastUsedUnicodeDirectory = nullptr;
|
||||
}
|
||||
mLastUsedUnicodeDirectory = ToNewUnicode(newDir);
|
||||
|
@ -633,7 +633,7 @@ private:
|
||||
|
||||
struct Block
|
||||
{
|
||||
// We create and destroy Block using NS_Alloc/NS_Free rather
|
||||
// We create and destroy Block using moz_xmalloc/free rather
|
||||
// than new and delete to avoid calling its constructor and
|
||||
// destructor.
|
||||
Block()
|
||||
@ -673,7 +673,7 @@ public:
|
||||
Block* b = mBlocks;
|
||||
while (b) {
|
||||
Block* n = b->mNext;
|
||||
NS_Free(b);
|
||||
free(b);
|
||||
b = n;
|
||||
}
|
||||
|
||||
@ -703,7 +703,7 @@ public:
|
||||
PtrInfo* Add(void* aPointer, nsCycleCollectionParticipant* aParticipant)
|
||||
{
|
||||
if (mNext == mBlockEnd) {
|
||||
Block* block = static_cast<Block*>(NS_Alloc(sizeof(Block)));
|
||||
Block* block = static_cast<Block*>(moz_xmalloc(sizeof(Block)));
|
||||
*mNextBlock = block;
|
||||
mNext = block->mEntries;
|
||||
mBlockEnd = block->mEntries + BlockSize;
|
||||
|
@ -10,7 +10,7 @@
|
||||
* nsIMemory: interface to allocate and deallocate memory. Also provides
|
||||
* for notifications in low-memory situations.
|
||||
*
|
||||
* The frozen exported symbols NS_Alloc, NS_Realloc, and NS_Free
|
||||
* The frozen exported symbols moz_xmalloc, moz_xrealloc, and free
|
||||
* provide a more efficient way to access XPCOM memory allocation. Using
|
||||
* those symbols is preferred to using the methods on this interface.
|
||||
*
|
||||
|
@ -185,24 +185,6 @@ nsMemoryImpl::sLastFlushTime = 0;
|
||||
nsMemoryImpl::FlushEvent
|
||||
nsMemoryImpl::sFlushEvent;
|
||||
|
||||
XPCOM_API(void*)
|
||||
NS_Alloc(size_t aSize)
|
||||
{
|
||||
return moz_xmalloc(aSize);
|
||||
}
|
||||
|
||||
XPCOM_API(void*)
|
||||
NS_Realloc(void* aPtr, size_t aSize)
|
||||
{
|
||||
return moz_xrealloc(aPtr, aSize);
|
||||
}
|
||||
|
||||
XPCOM_API(void)
|
||||
NS_Free(void* aPtr)
|
||||
{
|
||||
free(aPtr);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_GetMemoryManager(nsIMemory** aResult)
|
||||
{
|
||||
|
@ -84,14 +84,14 @@ nsUUIDGenerator::Init()
|
||||
NS_IMETHODIMP
|
||||
nsUUIDGenerator::GenerateUUID(nsID** aRet)
|
||||
{
|
||||
nsID* id = static_cast<nsID*>(NS_Alloc(sizeof(nsID)));
|
||||
nsID* id = static_cast<nsID*>(moz_xmalloc(sizeof(nsID)));
|
||||
if (!id) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult rv = GenerateUUIDInPlace(id);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_Free(id);
|
||||
free(id);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -62,9 +62,9 @@ static const XPCOMFunctions kFrozenFunctions = {
|
||||
&NS_CStringCloneData,
|
||||
|
||||
// these functions were added post 1.7 (post Firefox 1.0)
|
||||
&NS_Alloc,
|
||||
&NS_Realloc,
|
||||
&NS_Free,
|
||||
&moz_xmalloc,
|
||||
&moz_xrealloc,
|
||||
&free,
|
||||
&NS_StringContainerInit2,
|
||||
&NS_CStringContainerInit2,
|
||||
&NS_StringGetMutableData,
|
||||
|
@ -86,7 +86,7 @@ public:
|
||||
{
|
||||
Report();
|
||||
if (mFilename) {
|
||||
NS_Free(mFilename);
|
||||
free(mFilename);
|
||||
mFilename = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ public:
|
||||
Report();
|
||||
if (mFilename) {
|
||||
MOZ_ASSERT(mHasQueriedFilename);
|
||||
NS_Free(mFilename);
|
||||
free(mFilename);
|
||||
mFilename = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -917,7 +917,7 @@ ShutdownXPCOM(nsIServiceManager* aServMgr)
|
||||
// Release the directory service
|
||||
NS_IF_RELEASE(nsDirectoryService::gService);
|
||||
|
||||
NS_Free(gGREBinPath);
|
||||
free(gGREBinPath);
|
||||
gGREBinPath = nullptr;
|
||||
|
||||
if (moduleLoaders) {
|
||||
|
@ -162,6 +162,12 @@ XPCOM_API(nsresult) NS_NewNativeLocalFile(const nsACString& aPath,
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Allocator functions for the standalone glue.
|
||||
* Do not use outside the xpcom glue code.
|
||||
* Use moz_xmalloc/moz_xrealloc/free, or new/delete instead.
|
||||
*/
|
||||
#ifdef XPCOM_GLUE
|
||||
/**
|
||||
* Allocates a block of memory of a particular size. If the memory cannot
|
||||
* be allocated (because of an out-of-memory condition), the process aborts.
|
||||
@ -198,6 +204,11 @@ XPCOM_API(void*) NS_Realloc(void* aPtr, size_t aSize);
|
||||
* @note This function is thread-safe.
|
||||
*/
|
||||
XPCOM_API(void) NS_Free(void* aPtr);
|
||||
#else
|
||||
#define NS_Alloc moz_xmalloc
|
||||
#define NS_Realloc moz_xrealloc
|
||||
#define NS_Free free
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Support for warnings, assertions, and debugging breaks.
|
||||
|
@ -16,7 +16,7 @@ class nsIFile;
|
||||
* Application-specific data needed to start the apprunner.
|
||||
*
|
||||
* @note When this structure is allocated and manipulated by XRE_CreateAppData,
|
||||
* string fields will be allocated with NS_Alloc, and interface pointers
|
||||
* string fields will be allocated with moz_xmalloc, and interface pointers
|
||||
* are strong references.
|
||||
*/
|
||||
struct nsXREAppData
|
||||
|
@ -695,7 +695,7 @@ nsCategoryManager::AddCategoryEntry(const char* aCategoryName,
|
||||
if (aOldValue) {
|
||||
*aOldValue = oldEntry;
|
||||
} else {
|
||||
NS_Free(oldEntry);
|
||||
free(oldEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1036,7 +1036,7 @@ nsComponentManagerImpl::GetClassObject(const nsCID& aClass, const nsIID& aIID,
|
||||
char* buf = aClass.ToString();
|
||||
PR_LogPrint("nsComponentManager: GetClassObject(%s)", buf);
|
||||
if (buf) {
|
||||
NS_Free(buf);
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1160,7 +1160,7 @@ nsComponentManagerImpl::CreateInstance(const nsCID& aClass,
|
||||
("nsComponentManager: CreateInstance(%s) %s", buf,
|
||||
NS_SUCCEEDED(rv) ? "succeeded" : "FAILED"));
|
||||
if (buf) {
|
||||
NS_Free(buf);
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1832,7 +1832,7 @@ nsComponentManagerImpl::ContractIDToCID(const char* aContractID,
|
||||
SafeMutexAutoLock lock(mLock);
|
||||
nsFactoryEntry* entry = mContractIDs.Get(nsDependentCString(aContractID));
|
||||
if (entry) {
|
||||
*aResult = (nsCID*)NS_Alloc(sizeof(nsCID));
|
||||
*aResult = (nsCID*)moz_xmalloc(sizeof(nsCID));
|
||||
**aResult = *entry->mCIDEntry->cid;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1561,7 +1561,7 @@ nsVariant::AllocateWStringWithSize(nsDiscriminatedUnion* aData, uint32_t aSize)
|
||||
{
|
||||
DATA_SETTER_PROLOGUE(aData);
|
||||
if (!(aData->u.wstr.mWStringValue =
|
||||
(char16_t*)NS_Alloc((aSize + 1) * sizeof(char16_t)))) {
|
||||
(char16_t*)moz_xmalloc((aSize + 1) * sizeof(char16_t)))) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
aData->u.wstr.mWStringValue[aSize] = '\0';
|
||||
|
@ -315,7 +315,7 @@ nsBinaryOutputStream::WriteCompoundObject(nsISupports* aObject,
|
||||
|
||||
rv = WriteID(*cidptr);
|
||||
|
||||
NS_Free(cidptr);
|
||||
free(cidptr);
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
|
@ -104,9 +104,6 @@ nsEscapeCount(const char* aStr, nsEscapeMask aFlags, size_t* aOutLen)
|
||||
}
|
||||
|
||||
// fail if we need more than 4GB
|
||||
// size_t is likely to be long unsigned int but moz_xmalloc(size_t)
|
||||
// calls NS_Alloc_P(size_t) which calls PR_Malloc(uint32_t), so there is
|
||||
// no chance to allocate more than 4GB using moz_xmalloc()
|
||||
if (dstSize > UINT32_MAX) {
|
||||
return 0;
|
||||
}
|
||||
@ -233,7 +230,7 @@ nsEscapeHTML(const char* aString)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
rv = (char*)NS_Alloc((6 * len) + 1);
|
||||
rv = (char*)moz_xmalloc((6 * len) + 1);
|
||||
char* ptr = rv;
|
||||
|
||||
if (rv) {
|
||||
|
@ -240,7 +240,7 @@ _handle_union(const T* aStr, const T* aExpr, bool aCaseInsensitive,
|
||||
return ABORTED;
|
||||
}
|
||||
++cp; /* now index of char after closing parenthesis */
|
||||
e2 = (T*)NS_Alloc((1 + nsCharTraits<T>::length(aExpr)) * sizeof(T));
|
||||
e2 = (T*)moz_xmalloc((1 + nsCharTraits<T>::length(aExpr)) * sizeof(T));
|
||||
if (!e2) {
|
||||
return ABORTED;
|
||||
}
|
||||
@ -261,7 +261,7 @@ _handle_union(const T* aStr, const T* aExpr, bool aCaseInsensitive,
|
||||
break;
|
||||
}
|
||||
}
|
||||
NS_Free(e2);
|
||||
free(e2);
|
||||
if (sx < 2) {
|
||||
ret = ABORTED;
|
||||
}
|
||||
@ -426,7 +426,7 @@ ns_WildCardMatch(const T* aStr, const T* aXp, bool aCaseInsensitive)
|
||||
return ::_shexp_match(aStr, aXp, aCaseInsensitive, 0);
|
||||
}
|
||||
|
||||
expr = (T*)NS_Alloc((nsCharTraits<T>::length(aXp) + 1) * sizeof(T));
|
||||
expr = (T*)moz_xmalloc((nsCharTraits<T>::length(aXp) + 1) * sizeof(T));
|
||||
if (!expr) {
|
||||
return NOMATCH;
|
||||
}
|
||||
@ -451,7 +451,7 @@ ns_WildCardMatch(const T* aStr, const T* aXp, bool aCaseInsensitive)
|
||||
ret = ::_shexp_match(aStr, expr, aCaseInsensitive, 0);
|
||||
}
|
||||
|
||||
NS_Free(expr);
|
||||
free(expr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user