diff --git a/accessible/base/nsAccessiblePivot.cpp b/accessible/base/nsAccessiblePivot.cpp index 3d33f467e82..deee601cd1b 100644 --- a/accessible/base/nsAccessiblePivot.cpp +++ b/accessible/base/nsAccessiblePivot.cpp @@ -24,7 +24,7 @@ public: mAcceptRoles(nullptr) { } ~RuleCache () { if (mAcceptRoles) - nsMemory::Free(mAcceptRoles); + free(mAcceptRoles); } nsresult ApplyFilter(Accessible* aAccessible, uint16_t* aResult); diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp index 9c2432a9f64..a689abe7c42 100644 --- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -173,7 +173,7 @@ public: ~ClassInfoData() { if (mMustFreeName) - nsMemory::Free(mName); + free(mName); } uint32_t GetFlags() diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index e5b0bfbb708..566d76bfae9 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -11047,7 +11047,7 @@ nsDocShell::ScrollToAnchor(nsACString& aCurHash, nsACString& aNewHash, rv = shell->GoToAnchor(NS_ConvertUTF8toUTF16(str), scroll, nsIPresShell::SCROLL_SMOOTH_AUTO); } - nsMemory::Free(str); + free(str); // Above will fail if the anchor name is not UTF-8. Need to // convert from document charset to unicode. diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 5ceac0b2639..7fd791702d2 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -517,7 +517,7 @@ nsDOMClassInfo::RegisterExternalClasses() } rv = nameSpaceManager->RegisterExternalClassName(categoryEntry.get(), *cid); - nsMemory::Free(cid); + free(cid); NS_ENSURE_SUCCESS(rv, rv); } @@ -808,7 +808,7 @@ nsDOMClassInfo::GetInterfaces(uint32_t *aCount, nsIID ***aArray) return NS_OK; } - *aArray = static_cast(nsMemory::Alloc(count * sizeof(nsIID *))); + *aArray = static_cast(moz_xmalloc(count * sizeof(nsIID *))); NS_ENSURE_TRUE(*aArray, NS_ERROR_OUT_OF_MEMORY); uint32_t i; diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index c4789c6689d..ad1a98c382f 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -2527,7 +2527,7 @@ nsDOMWindowUtils::StopFrameTimeRecording(uint32_t startIndex, mgr->StopFrameTimeRecording(startIndex, tmpFrameIntervals); *frameCount = tmpFrameIntervals.Length(); - *frameIntervals = (float*)nsMemory::Alloc(*frameCount * sizeof(float)); + *frameIntervals = (float*)moz_xmalloc(*frameCount * sizeof(float)); /* copy over the frame intervals and paint times into the arrays we just allocated */ for (uint32_t i = 0; i < *frameCount; i++) { diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 27f3d357d90..67155b29704 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -10087,7 +10087,7 @@ nsDocument::ScrollToRef() nsUnescape(tmpstr); nsAutoCString unescapedRef; unescapedRef.Assign(tmpstr); - nsMemory::Free(tmpstr); + free(tmpstr); nsresult rv = NS_ERROR_FAILURE; // We assume that the bytes are in UTF-8, as it says in the spec: diff --git a/dom/base/nsFormData.cpp b/dom/base/nsFormData.cpp index 20ca773ae3c..5e1203929a8 100644 --- a/dom/base/nsFormData.cpp +++ b/dom/base/nsFormData.cpp @@ -240,7 +240,7 @@ nsFormData::Append(const nsAString& aName, nsIVariant* aValue) rv = aValue->GetAsInterface(&iid, getter_AddRefs(supports)); NS_ENSURE_SUCCESS(rv, rv); - nsMemory::Free(iid); + free(iid); nsCOMPtr domBlob = do_QueryInterface(supports); nsRefPtr blob = static_cast(domBlob.get()); diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 6d2694fa9f3..699be0fa86c 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -6091,7 +6091,7 @@ nsGlobalWindow::Dump(const nsAString& aStr) FILE *fp = gDumpFile ? gDumpFile : stdout; fputs(cstr, fp); fflush(fp); - nsMemory::Free(cstr); + free(cstr); } return NS_OK; diff --git a/dom/base/nsHTMLContentSerializer.cpp b/dom/base/nsHTMLContentSerializer.cpp index 65cd9e76235..7ee26af4d35 100644 --- a/dom/base/nsHTMLContentSerializer.cpp +++ b/dom/base/nsHTMLContentSerializer.cpp @@ -587,7 +587,7 @@ nsHTMLContentSerializer::AppendAndTranslateEntities(const nsAString& aStr, // if it comes from nsIEntityConverter, it already has '&' and ';' else if (fullEntityText) { bool ok = AppendASCIItoUTF16(fullEntityText, aOutputStr, mozilla::fallible); - nsMemory::Free(fullEntityText); + free(fullEntityText); advanceLength += lengthReplaced; NS_ENSURE_TRUE(ok, false); } diff --git a/dom/base/nsHostObjectURI.cpp b/dom/base/nsHostObjectURI.cpp index 64de0c6f025..b2ff2c93633 100644 --- a/dom/base/nsHostObjectURI.cpp +++ b/dom/base/nsHostObjectURI.cpp @@ -228,7 +228,7 @@ nsHostObjectURI::GetClassID(nsCID * *aClassID) { // Make sure to modify any subclasses as needed if this ever // changes to not call the virtual GetClassIDNoAlloc. - *aClassID = (nsCID*) nsMemory::Alloc(sizeof(nsCID)); + *aClassID = (nsCID*) moz_xmalloc(sizeof(nsCID)); NS_ENSURE_TRUE(*aClassID, NS_ERROR_OUT_OF_MEMORY); return GetClassIDNoAlloc(*aClassID); diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index bb3d6137ba6..5725fb36f0a 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -317,7 +317,7 @@ public: } ~AutoFree() { if (mPtr) - nsMemory::Free(mPtr); + free(mPtr); } void Invalidate() { mPtr = 0; diff --git a/dom/base/nsPlainTextSerializer.cpp b/dom/base/nsPlainTextSerializer.cpp index b9db9c7d268..2b7d56be0fa 100644 --- a/dom/base/nsPlainTextSerializer.cpp +++ b/dom/base/nsPlainTextSerializer.cpp @@ -1710,7 +1710,7 @@ nsPlainTextSerializer::Write(const nsAString& aStr) foo = ToNewCString(remaining); // printf("Next line: bol = %d, newlinepos = %d, totLen = %d, string = '%s'\n", // bol, nextpos, totLen, foo); - nsMemory::Free(foo); + free(foo); #endif if (nextpos == kNotFound) { diff --git a/dom/base/nsScriptNameSpaceManager.cpp b/dom/base/nsScriptNameSpaceManager.cpp index 021bd02f36e..e7282beebd2 100644 --- a/dom/base/nsScriptNameSpaceManager.cpp +++ b/dom/base/nsScriptNameSpaceManager.cpp @@ -634,7 +634,7 @@ nsScriptNameSpaceManager::OperateCategoryEntryHash(nsICategoryManager* aCategory // Copy CID onto the stack, so we can free it right away and avoid having // to add cleanup code at every exit point from this function. nsCID cid = *cidPtr; - nsMemory::Free(cidPtr); + free(cidPtr); if (type == nsGlobalNameStruct::eTypeExternalConstructor) { nsXPIDLCString constructorProto; diff --git a/dom/base/nsXMLHttpRequest.cpp b/dom/base/nsXMLHttpRequest.cpp index 320b136af94..0ccd4eb90d2 100644 --- a/dom/base/nsXMLHttpRequest.cpp +++ b/dom/base/nsXMLHttpRequest.cpp @@ -2466,7 +2466,7 @@ GetRequestBody(nsIVariant* aBody, nsIInputStream** aResult, uint64_t* aContentLe rv = aBody->GetAsInterface(&iid, getter_AddRefs(supports)); NS_ENSURE_SUCCESS(rv, rv); - nsMemory::Free(iid); + free(iid); // document? nsCOMPtr doc = do_QueryInterface(supports); diff --git a/dom/canvas/WebGL2ContextTransformFeedback.cpp b/dom/canvas/WebGL2ContextTransformFeedback.cpp index d83cc9d3df6..17a13312bca 100644 --- a/dom/canvas/WebGL2ContextTransformFeedback.cpp +++ b/dom/canvas/WebGL2ContextTransformFeedback.cpp @@ -206,7 +206,7 @@ WebGL2Context::TransformFeedbackVaryings(WebGLProgram* program, return; GLsizei count = varyings.Length(); - GLchar** tmpVaryings = (GLchar**) nsMemory::Alloc(count * sizeof(GLchar*)); + GLchar** tmpVaryings = (GLchar**) moz_xmalloc(count * sizeof(GLchar*)); for (GLsizei n = 0; n < count; n++) { tmpVaryings[n] = (GLchar*) ToNewCString(varyings[n]); diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp index 387e68ad710..5f1f67e366f 100644 --- a/dom/events/Event.cpp +++ b/dom/events/Event.cpp @@ -858,7 +858,7 @@ void Event::PopupAllowedEventsChanged() { if (sPopupAllowedEvents) { - nsMemory::Free(sPopupAllowedEvents); + free(sPopupAllowedEvents); } nsAdoptingCString str = Preferences::GetCString("dom.popup_allowed_events"); @@ -873,7 +873,7 @@ void Event::Shutdown() { if (sPopupAllowedEvents) { - nsMemory::Free(sPopupAllowedEvents); + free(sPopupAllowedEvents); } } diff --git a/dom/events/EventListenerService.cpp b/dom/events/EventListenerService.cpp index 429b9ca3c0c..593b8521e8b 100644 --- a/dom/events/EventListenerService.cpp +++ b/dom/events/EventListenerService.cpp @@ -152,7 +152,7 @@ EventListenerService::GetListenerInfoFor(nsIDOMEventTarget* aEventTarget, *aOutArray = static_cast( - nsMemory::Alloc(sizeof(nsIEventListenerInfo*) * count)); + moz_xmalloc(sizeof(nsIEventListenerInfo*) * count)); NS_ENSURE_TRUE(*aOutArray, NS_ERROR_OUT_OF_MEMORY); for (int32_t i = 0; i < count; ++i) { @@ -182,7 +182,7 @@ EventListenerService::GetEventTargetChainFor(nsIDOMEventTarget* aEventTarget, *aOutArray = static_cast( - nsMemory::Alloc(sizeof(nsIDOMEventTarget*) * count)); + moz_xmalloc(sizeof(nsIDOMEventTarget*) * count)); NS_ENSURE_TRUE(*aOutArray, NS_ERROR_OUT_OF_MEMORY); for (int32_t i = 0; i < count; ++i) { diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index aea672ef093..5c0b91b64e3 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -1179,7 +1179,7 @@ void HTMLInputElement::FreeData() { if (!IsSingleLineTextControl(false)) { - nsMemory::Free(mInputData.mValue); + free(mInputData.mValue); mInputData.mValue = nullptr; } else { UnbindFromFrame(nullptr); @@ -2895,7 +2895,7 @@ HTMLInputElement::SetValueInternal(const nsAString& aValue, UpdateAllValidityStates(mParserCreating); } } else { - nsMemory::Free(mInputData.mValue); + free(mInputData.mValue); mInputData.mValue = ToNewUnicode(value); if (aSetValueChanged) { SetValueChanged(true); diff --git a/dom/html/nsFormSubmission.cpp b/dom/html/nsFormSubmission.cpp index edc788bd4bd..e75f1b3215b 100644 --- a/dom/html/nsFormSubmission.cpp +++ b/dom/html/nsFormSubmission.cpp @@ -360,7 +360,7 @@ nsFSURLEncoded::URLEncode(const nsAString& aStr, nsCString& aEncoded) nsAutoCString encodedBuf; nsresult rv = EncodeVal(nsDependentString(convertedBuf), encodedBuf, false); - nsMemory::Free(convertedBuf); + free(convertedBuf); NS_ENSURE_SUCCESS(rv, rv); char* escapedBuf = nsEscape(encodedBuf.get(), url_XPAlphas); diff --git a/dom/html/nsHTMLDocument.cpp b/dom/html/nsHTMLDocument.cpp index 7429df35830..f04cb3675b8 100644 --- a/dom/html/nsHTMLDocument.cpp +++ b/dom/html/nsHTMLDocument.cpp @@ -3469,7 +3469,7 @@ nsHTMLDocument::QueryCommandState(const nsAString& commandID, ErrorResult& rv) retval = paramToCheck.Equals(actualAlignmentType); } if (actualAlignmentType) { - nsMemory::Free(actualAlignmentType); + free(actualAlignmentType); } return retval; } diff --git a/dom/mobileconnection/MobileConnection.cpp b/dom/mobileconnection/MobileConnection.cpp index 5ec69798df8..256489c5e80 100644 --- a/dom/mobileconnection/MobileConnection.cpp +++ b/dom/mobileconnection/MobileConnection.cpp @@ -439,7 +439,7 @@ MobileConnection::GetSupportedNetworkTypes(nsTArray& aTypes) aTypes.AppendElement(static_cast(type)); } - nsMemory::Free(types); + free(types); } already_AddRefed diff --git a/dom/mobileconnection/ipc/MobileConnectionChild.cpp b/dom/mobileconnection/ipc/MobileConnectionChild.cpp index f52de35780d..dab7aae81e3 100644 --- a/dom/mobileconnection/ipc/MobileConnectionChild.cpp +++ b/dom/mobileconnection/ipc/MobileConnectionChild.cpp @@ -114,7 +114,7 @@ MobileConnectionChild::GetSupportedNetworkTypes(int32_t** aTypes, *aLength = mSupportedNetworkTypes.Length(); *aTypes = - static_cast(nsMemory::Alloc((*aLength) * sizeof(int32_t))); + static_cast(moz_xmalloc((*aLength) * sizeof(int32_t))); NS_ENSURE_TRUE(*aTypes, NS_ERROR_OUT_OF_MEMORY); for (uint32_t i = 0; i < *aLength; i++) { diff --git a/dom/mobileconnection/ipc/MobileConnectionParent.cpp b/dom/mobileconnection/ipc/MobileConnectionParent.cpp index eac21dd0778..7956fa65c68 100644 --- a/dom/mobileconnection/ipc/MobileConnectionParent.cpp +++ b/dom/mobileconnection/ipc/MobileConnectionParent.cpp @@ -147,7 +147,7 @@ MobileConnectionParent::RecvInit(nsMobileConnectionInfo* aVoice, aSupportedNetworkTypes->AppendElement(types[i]); } - nsMemory::Free(types); + free(types); return true; } diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index f0d07fae960..f0f8c143494 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -1112,7 +1112,7 @@ _memfree (void *ptr) NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY, ("NPN_MemFree: ptr=%p\n", ptr)); if (ptr) - nsMemory::Free(ptr); + free(ptr); } uint32_t @@ -2539,7 +2539,7 @@ _memalloc (uint32_t size) NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,("NPN_memalloc called from the wrong thread\n")); } NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY, ("NPN_MemAlloc: size=%d\n", size)); - return nsMemory::Alloc(size); + return moz_xmalloc(size); } // Deprecated, only stubbed out diff --git a/dom/plugins/base/nsNPAPIPluginInstance.cpp b/dom/plugins/base/nsNPAPIPluginInstance.cpp index 9d4e8f28132..6ef78fa6f14 100644 --- a/dom/plugins/base/nsNPAPIPluginInstance.cpp +++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp @@ -1293,7 +1293,7 @@ nsNPAPIPluginInstance::GetFormValue(nsAString& aValue) // NPPVformValue allocates with NPN_MemAlloc(), which uses // nsMemory. - nsMemory::Free(value); + free(value); return NS_OK; } diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp index ea591ab1079..93ffa0fb615 100644 --- a/dom/plugins/base/nsPluginHost.cpp +++ b/dom/plugins/base/nsPluginHost.cpp @@ -1128,7 +1128,7 @@ nsPluginHost::GetPluginTags(uint32_t* aPluginCount, nsIPluginTag*** aResults) } *aResults = static_cast - (nsMemory::Alloc(count * sizeof(**aResults))); + (moz_xmalloc(count * sizeof(**aResults))); if (!*aResults) return NS_ERROR_OUT_OF_MEMORY; @@ -3509,7 +3509,7 @@ nsPluginHost::ParsePostBufferToFixHeaders(const char *inPostData, uint32_t inPos int cntSingleLF = singleLF.Length(); newBufferLen += cntSingleLF; - if (!(*outPostData = p = (char*)nsMemory::Alloc(newBufferLen))) + if (!(*outPostData = p = (char*)moz_xmalloc(newBufferLen))) return NS_ERROR_OUT_OF_MEMORY; // deal with single LF @@ -3538,11 +3538,11 @@ nsPluginHost::ParsePostBufferToFixHeaders(const char *inPostData, uint32_t inPos // to keep ContentLenHeader+value followed by data uint32_t l = sizeof(ContentLenHeader) + sizeof(CRLFCRLF) + 32; newBufferLen = dataLen + l; - if (!(*outPostData = p = (char*)nsMemory::Alloc(newBufferLen))) + if (!(*outPostData = p = (char*)moz_xmalloc(newBufferLen))) return NS_ERROR_OUT_OF_MEMORY; headersLen = PR_snprintf(p, l,"%s: %ld%s", ContentLenHeader, dataLen, CRLFCRLF); if (headersLen == l) { // if PR_snprintf has ate all extra space consider this as an error - nsMemory::Free(p); + free(p); *outPostData = 0; return NS_ERROR_FAILURE; } @@ -3642,7 +3642,7 @@ nsPluginHost::CreateTempFileToPost(const char *aPostDataURL, nsIFile **aTmpFile) // lets parse it through nsPluginHost::ParsePostBufferToFixHeaders() ParsePostBufferToFixHeaders((const char *)buf, br, &parsedBuf, &bw); rv = outStream->Write(parsedBuf, bw, &br); - nsMemory::Free(parsedBuf); + free(parsedBuf); if (NS_FAILED(rv) || (bw != br)) break; diff --git a/dom/plugins/base/nsPluginTags.cpp b/dom/plugins/base/nsPluginTags.cpp index d8d57457632..7e0be6170e6 100644 --- a/dom/plugins/base/nsPluginTags.cpp +++ b/dom/plugins/base/nsPluginTags.cpp @@ -122,7 +122,7 @@ CStringArrayToXPCArray(nsTArray & aArray, } *aResults = - static_cast(nsMemory::Alloc(count * sizeof(**aResults))); + static_cast(moz_xmalloc(count * sizeof(**aResults))); *aCount = count; for (uint32_t i = 0; i < count; i++) { diff --git a/dom/xbl/nsXBLProtoImplField.cpp b/dom/xbl/nsXBLProtoImplField.cpp index 77eaf0346b8..2011ff64d88 100644 --- a/dom/xbl/nsXBLProtoImplField.cpp +++ b/dom/xbl/nsXBLProtoImplField.cpp @@ -62,7 +62,7 @@ nsXBLProtoImplField::~nsXBLProtoImplField() { MOZ_COUNT_DTOR(nsXBLProtoImplField); if (mFieldText) - nsMemory::Free(mFieldText); + free(mFieldText); NS_Free(mName); NS_CONTENT_DELETE_LIST_MEMBER(nsXBLProtoImplField, this, mNext); } @@ -76,7 +76,7 @@ nsXBLProtoImplField::AppendFieldText(const nsAString& aText) char16_t* temp = mFieldText; mFieldText = ToNewUnicode(newFieldText); mFieldTextLength = newFieldText.Length(); - nsMemory::Free(temp); + free(temp); } else { mFieldText = ToNewUnicode(aText); diff --git a/dom/xbl/nsXBLProtoImplMember.h b/dom/xbl/nsXBLProtoImplMember.h index e12df150155..0de828b3804 100644 --- a/dom/xbl/nsXBLProtoImplMember.h +++ b/dom/xbl/nsXBLProtoImplMember.h @@ -31,7 +31,7 @@ struct nsXBLTextWithLineNumber ~nsXBLTextWithLineNumber() { MOZ_COUNT_DTOR(nsXBLTextWithLineNumber); if (mText) { - nsMemory::Free(mText); + free(mText); } } @@ -39,7 +39,7 @@ struct nsXBLTextWithLineNumber if (mText) { char16_t* temp = mText; mText = ToNewUnicode(nsDependentString(temp) + aText); - nsMemory::Free(temp); + free(temp); } else { mText = ToNewUnicode(aText); } @@ -68,7 +68,7 @@ public: mName = ToNewUnicode(nsDependentString(aName)); } virtual ~nsXBLProtoImplMember() { - nsMemory::Free(mName); + free(mName); NS_CONTENT_DELETE_LIST_MEMBER(nsXBLProtoImplMember, this, mNext); } diff --git a/dom/xbl/nsXBLProtoImplMethod.h b/dom/xbl/nsXBLProtoImplMethod.h index f3c63022f5f..32ab0021371 100644 --- a/dom/xbl/nsXBLProtoImplMethod.h +++ b/dom/xbl/nsXBLProtoImplMethod.h @@ -28,7 +28,7 @@ struct nsXBLParameter { ~nsXBLParameter() { MOZ_COUNT_DTOR(nsXBLParameter); - nsMemory::Free(mName); + free(mName); NS_CONTENT_DELETE_LIST_MEMBER(nsXBLParameter, this, mNext); } }; diff --git a/dom/xbl/nsXBLPrototypeBinding.cpp b/dom/xbl/nsXBLPrototypeBinding.cpp index e852a905a9e..0b0c1768ca3 100644 --- a/dom/xbl/nsXBLPrototypeBinding.cpp +++ b/dom/xbl/nsXBLPrototypeBinding.cpp @@ -701,7 +701,7 @@ nsXBLPrototypeBinding::ConstructAttributeTable(nsIContent* aElement) token = nsCRT::strtok( newStr, ", ", &newStr ); } - nsMemory::Free(str); + free(str); } } diff --git a/dom/xbl/nsXBLPrototypeHandler.cpp b/dom/xbl/nsXBLPrototypeHandler.cpp index 7ad1be42505..68e651c7dbb 100644 --- a/dom/xbl/nsXBLPrototypeHandler.cpp +++ b/dom/xbl/nsXBLPrototypeHandler.cpp @@ -124,7 +124,7 @@ nsXBLPrototypeHandler::~nsXBLPrototypeHandler() if (mType & NS_HANDLER_TYPE_XUL) { NS_IF_RELEASE(mHandlerElement); } else if (mHandlerText) { - nsMemory::Free(mHandlerText); + free(mHandlerText); } // We own the next handler in the chain, so delete it now. @@ -149,7 +149,7 @@ nsXBLPrototypeHandler::AppendHandlerText(const nsAString& aText) // Append our text to the existing text. char16_t* temp = mHandlerText; mHandlerText = ToNewUnicode(nsDependentString(temp) + aText); - nsMemory::Free(temp); + free(temp); } else { mHandlerText = ToNewUnicode(aText); @@ -834,7 +834,7 @@ nsXBLPrototypeHandler::ConstructPrototype(nsIContent* aKeyElement, token = nsCRT::strtok( newStr, ", \t", &newStr ); } - nsMemory::Free(str); + free(str); } nsAutoString key(aCharCode); diff --git a/dom/xslt/xpath/txNodeSet.cpp b/dom/xslt/xpath/txNodeSet.cpp index 645e3083a53..8611fd7fb62 100644 --- a/dom/xslt/xpath/txNodeSet.cpp +++ b/dom/xslt/xpath/txNodeSet.cpp @@ -84,7 +84,7 @@ txNodeSet::~txNodeSet() if (mStartBuffer) { destroyElements(mStart, mEnd); - nsMemory::Free(mStartBuffer); + free(mStartBuffer); } } @@ -137,7 +137,7 @@ nsresult txNodeSet::addAndTransfer(txNodeSet* aNodes) #ifdef TX_DONT_RECYCLE_BUFFER if (aNodes->mStartBuffer) { - nsMemory::Free(aNodes->mStartBuffer); + free(aNodes->mStartBuffer); aNodes->mStartBuffer = aNodes->mEndBuffer = nullptr; } #endif @@ -412,7 +412,7 @@ txNodeSet::clear() destroyElements(mStart, mEnd); #ifdef TX_DONT_RECYCLE_BUFFER if (mStartBuffer) { - nsMemory::Free(mStartBuffer); + free(mStartBuffer); mStartBuffer = mEndBuffer = nullptr; } #endif @@ -527,7 +527,7 @@ bool txNodeSet::ensureGrowSize(int32_t aSize) } txXPathNode* newArr = static_cast - (nsMemory::Alloc(newLength * + (moz_xmalloc(newLength * sizeof(txXPathNode))); if (!newArr) { return false; @@ -548,7 +548,7 @@ bool txNodeSet::ensureGrowSize(int32_t aSize) memset(mStartBuffer, 0, (mEndBuffer - mStartBuffer) * sizeof(txXPathNode)); #endif - nsMemory::Free(mStartBuffer); + free(mStartBuffer); } mStartBuffer = newArr; diff --git a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp index e05e2a0fbb5..08fef4599da 100644 --- a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp +++ b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp @@ -892,7 +892,7 @@ txMozillaXSLTProcessor::SetParameter(const nsAString & aNamespaceURI, if (type != nsIDataType::VTYPE_INTERFACE && type != nsIDataType::VTYPE_INTERFACE_IS) { - nsMemory::Free(array); + free(array); // We only support arrays of DOM nodes. return NS_ERROR_ILLEGAL_VALUE; @@ -919,7 +919,7 @@ txMozillaXSLTProcessor::SetParameter(const nsAString & aNamespaceURI, NS_IF_RELEASE(values[i]); ++i; } - nsMemory::Free(array); + free(array); return rv; } @@ -927,7 +927,7 @@ txMozillaXSLTProcessor::SetParameter(const nsAString & aNamespaceURI, NS_RELEASE(supports); } - nsMemory::Free(array); + free(array); break; } @@ -1579,7 +1579,7 @@ txVariable::Convert(nsIVariant *aValue, txAExprResult** aResult) NS_RELEASE(values[i]); ++i; } - nsMemory::Free(array); + free(array); return NS_ERROR_FAILURE; } @@ -1589,7 +1589,7 @@ txVariable::Convert(nsIVariant *aValue, txAExprResult** aResult) NS_RELEASE(supports); } - nsMemory::Free(array); + free(array); NS_ADDREF(*aResult = nodeSet); diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp index 29fb260e897..8570b56f0fe 100644 --- a/dom/xul/XULDocument.cpp +++ b/dom/xul/XULDocument.cpp @@ -4371,7 +4371,7 @@ XULDocument::InsertElement(nsINode* aParent, nsIContent* aChild, token = nsCRT::strtok(rest, ", ", &rest); } - nsMemory::Free(str); + free(str); if (content) { int32_t pos = aParent->IndexOf(content); diff --git a/editor/composer/nsEditorSpellCheck.cpp b/editor/composer/nsEditorSpellCheck.cpp index f373a01aa07..f0dac8eee7c 100644 --- a/editor/composer/nsEditorSpellCheck.cpp +++ b/editor/composer/nsEditorSpellCheck.cpp @@ -544,7 +544,7 @@ nsEditorSpellCheck::GetDictionaryList(char16_t ***aDictionaryList, uint32_t *aCo // If there are no dictionaries, return an array containing // one element and a count of one. - tmpPtr = (char16_t **)nsMemory::Alloc(sizeof(char16_t *)); + tmpPtr = (char16_t **)moz_xmalloc(sizeof(char16_t *)); NS_ENSURE_TRUE(tmpPtr, NS_ERROR_OUT_OF_MEMORY); @@ -555,7 +555,7 @@ nsEditorSpellCheck::GetDictionaryList(char16_t ***aDictionaryList, uint32_t *aCo return NS_OK; } - tmpPtr = (char16_t **)nsMemory::Alloc(sizeof(char16_t *) * dictList.Length()); + tmpPtr = (char16_t **)moz_xmalloc(sizeof(char16_t *) * dictList.Length()); NS_ENSURE_TRUE(tmpPtr, NS_ERROR_OUT_OF_MEMORY); diff --git a/extensions/auth/nsAuthSASL.cpp b/extensions/auth/nsAuthSASL.cpp index 75830d365f6..2c72cb0ac55 100644 --- a/extensions/auth/nsAuthSASL.cpp +++ b/extensions/auth/nsAuthSASL.cpp @@ -100,11 +100,11 @@ nsAuthSASL::GetNextToken(const void *inToken, // If we were doing security layers then we'd care what the // server had sent us. We're not, so all we had to do was make // sure that the signature was correct with the above unwrap() - nsMemory::Free(unwrappedToken); + free(unwrappedToken); NS_CopyUnicodeToNative(mUsername, userbuf); messageLen = userbuf.Length() + 4 + 1; - message = (char *)nsMemory::Alloc(messageLen); + message = (char *)moz_xmalloc(messageLen); if (!message) { Reset(); return NS_ERROR_OUT_OF_MEMORY; @@ -118,7 +118,7 @@ nsAuthSASL::GetNextToken(const void *inToken, // when wrapping the message rv = mInnerModule->Wrap((void *) message, messageLen-1, false, outToken, outTokenLen); - nsMemory::Free(message); + free(message); Reset(); // All done return NS_SUCCEEDED(rv) ? NS_SUCCESS_AUTH_FINISHED : rv; } diff --git a/extensions/auth/nsAuthSSPI.cpp b/extensions/auth/nsAuthSSPI.cpp index 27b68155893..c5c00357e26 100644 --- a/extensions/auth/nsAuthSSPI.cpp +++ b/extensions/auth/nsAuthSSPI.cpp @@ -167,7 +167,7 @@ nsAuthSSPI::Reset() mIsFirst = true; if (mCertDERData){ - nsMemory::Free(mCertDERData); + free(mCertDERData); mCertDERData = nullptr; mCertDERLength = 0; } @@ -334,7 +334,7 @@ nsAuthSSPI::GetNextToken(const void *inToken, // the token represents the server certificate. mIsFirst = false; mCertDERLength = inTokenLen; - mCertDERData = nsMemory::Alloc(inTokenLen); + mCertDERData = moz_xmalloc(inTokenLen); if (!mCertDERData) return NS_ERROR_OUT_OF_MEMORY; memcpy(mCertDERData, inToken, inTokenLen); @@ -378,7 +378,7 @@ nsAuthSSPI::GetNextToken(const void *inToken, pendpoint_binding.cbApplicationDataLength + pendpoint_binding.dwApplicationDataOffset; - sspi_cbt = (char *) nsMemory::Alloc(ib[ibd.cBuffers].cbBuffer); + sspi_cbt = (char *) moz_xmalloc(ib[ibd.cBuffers].cbBuffer); if (!sspi_cbt){ return NS_ERROR_OUT_OF_MEMORY; } @@ -410,10 +410,10 @@ nsAuthSSPI::GetNextToken(const void *inToken, if (NS_SUCCEEDED(rv)) rv = crypto->Finish(false, hashString); if (NS_FAILED(rv)) { - nsMemory::Free(mCertDERData); + free(mCertDERData); mCertDERData = nullptr; mCertDERLength = 0; - nsMemory::Free(sspi_cbt); + free(sspi_cbt); return rv; } @@ -423,7 +423,7 @@ nsAuthSSPI::GetNextToken(const void *inToken, memcpy(sspi_cbt_ptr, hashString.get(), hash_size); // Free memory used to store the server certificate - nsMemory::Free(mCertDERData); + free(mCertDERData); mCertDERData = nullptr; mCertDERLength = 0; } // End of CBT computation. @@ -453,10 +453,10 @@ nsAuthSSPI::GetNextToken(const void *inToken, obd.pBuffers = &ob; ob.BufferType = SECBUFFER_TOKEN; ob.cbBuffer = mMaxTokenLen; - ob.pvBuffer = nsMemory::Alloc(ob.cbBuffer); + ob.pvBuffer = moz_xmalloc(ob.cbBuffer); if (!ob.pvBuffer){ if (sspi_cbt) - nsMemory::Free(sspi_cbt); + free(sspi_cbt); return NS_ERROR_OUT_OF_MEMORY; } memset(ob.pvBuffer, 0, ob.cbBuffer); @@ -485,10 +485,10 @@ nsAuthSSPI::GetNextToken(const void *inToken, LOG(("InitializeSecurityContext: continue.\n")); #endif if (sspi_cbt) - nsMemory::Free(sspi_cbt); + free(sspi_cbt); if (!ob.cbBuffer) { - nsMemory::Free(ob.pvBuffer); + free(ob.pvBuffer); ob.pvBuffer = nullptr; } *outToken = ob.pvBuffer; @@ -502,7 +502,7 @@ nsAuthSSPI::GetNextToken(const void *inToken, LOG(("InitializeSecurityContext failed [rc=%d:%s]\n", rc, MapErrorCode(rc))); Reset(); - nsMemory::Free(ob.pvBuffer); + free(ob.pvBuffer); return NS_ERROR_FAILURE; } @@ -523,7 +523,7 @@ nsAuthSSPI::Unwrap(const void *inToken, // SSPI Buf ib[0].BufferType = SECBUFFER_STREAM; ib[0].cbBuffer = inTokenLen; - ib[0].pvBuffer = nsMemory::Alloc(ib[0].cbBuffer); + ib[0].pvBuffer = moz_xmalloc(ib[0].cbBuffer); if (!ib[0].pvBuffer) return NS_ERROR_OUT_OF_MEMORY; @@ -550,14 +550,14 @@ nsAuthSSPI::Unwrap(const void *inToken, } else { *outToken = nsMemory::Clone(ib[1].pvBuffer, ib[1].cbBuffer); - nsMemory::Free(ib[0].pvBuffer); + free(ib[0].pvBuffer); if (!*outToken) return NS_ERROR_OUT_OF_MEMORY; } *outTokenLen = ib[1].cbBuffer; } else - nsMemory::Free(ib[0].pvBuffer); + free(ib[0].pvBuffer); if (!SEC_SUCCESS(rc)) return NS_ERROR_FAILURE; @@ -577,13 +577,13 @@ public: ~secBuffers() { if (ib[0].pvBuffer) - nsMemory::Free(ib[0].pvBuffer); + free(ib[0].pvBuffer); if (ib[1].pvBuffer) - nsMemory::Free(ib[1].pvBuffer); + free(ib[1].pvBuffer); if (ib[2].pvBuffer) - nsMemory::Free(ib[2].pvBuffer); + free(ib[2].pvBuffer); } }; @@ -615,14 +615,14 @@ nsAuthSSPI::Wrap(const void *inToken, // SSPI bufs.ib[0].cbBuffer = sizes.cbSecurityTrailer; bufs.ib[0].BufferType = SECBUFFER_TOKEN; - bufs.ib[0].pvBuffer = nsMemory::Alloc(sizes.cbSecurityTrailer); + bufs.ib[0].pvBuffer = moz_xmalloc(sizes.cbSecurityTrailer); if (!bufs.ib[0].pvBuffer) return NS_ERROR_OUT_OF_MEMORY; // APP Data bufs.ib[1].BufferType = SECBUFFER_DATA; - bufs.ib[1].pvBuffer = nsMemory::Alloc(inTokenLen); + bufs.ib[1].pvBuffer = moz_xmalloc(inTokenLen); bufs.ib[1].cbBuffer = inTokenLen; if (!bufs.ib[1].pvBuffer) @@ -633,7 +633,7 @@ nsAuthSSPI::Wrap(const void *inToken, // SSPI bufs.ib[2].BufferType = SECBUFFER_PADDING; bufs.ib[2].cbBuffer = sizes.cbBlockSize; - bufs.ib[2].pvBuffer = nsMemory::Alloc(bufs.ib[2].cbBuffer); + bufs.ib[2].pvBuffer = moz_xmalloc(bufs.ib[2].cbBuffer); if (!bufs.ib[2].pvBuffer) return NS_ERROR_OUT_OF_MEMORY; @@ -644,7 +644,7 @@ nsAuthSSPI::Wrap(const void *inToken, if (SEC_SUCCESS(rc)) { int len = bufs.ib[0].cbBuffer + bufs.ib[1].cbBuffer + bufs.ib[2].cbBuffer; - char *p = (char *) nsMemory::Alloc(len); + char *p = (char *) moz_xmalloc(len); if (!p) return NS_ERROR_OUT_OF_MEMORY; diff --git a/extensions/auth/nsAuthSambaNTLM.cpp b/extensions/auth/nsAuthSambaNTLM.cpp index 7cbf12894d5..432ceae446b 100644 --- a/extensions/auth/nsAuthSambaNTLM.cpp +++ b/extensions/auth/nsAuthSambaNTLM.cpp @@ -263,7 +263,6 @@ nsAuthSambaNTLM::GetNextToken(const void *inToken, uint8_t* buf = ExtractMessage(line, outTokenLen); if (!buf) return NS_ERROR_FAILURE; - // *outToken has to be freed by nsMemory::Free, which may not be free() *outToken = nsMemory::Clone(buf, *outTokenLen); free(buf); if (!*outToken) { diff --git a/extensions/auth/nsHttpNegotiateAuth.cpp b/extensions/auth/nsHttpNegotiateAuth.cpp index dab22b93f54..7bd582b1a86 100644 --- a/extensions/auth/nsHttpNegotiateAuth.cpp +++ b/extensions/auth/nsHttpNegotiateAuth.cpp @@ -268,7 +268,7 @@ nsHttpNegotiateAuth::GenerateCredentials(nsIHttpAuthenticableChannel *authChanne // char *encoded_token = PL_Base64Encode((char *)outToken, outTokenLen, nullptr); - nsMemory::Free(outToken); + free(outToken); if (!encoded_token) return NS_ERROR_OUT_OF_MEMORY; @@ -276,7 +276,7 @@ nsHttpNegotiateAuth::GenerateCredentials(nsIHttpAuthenticableChannel *authChanne LOG((" Sending a token of length %d\n", outTokenLen)); // allocate a buffer sizeof("Negotiate" + " " + b64output_token + "\0") - *creds = (char *) nsMemory::Alloc(kNegotiateLen + 1 + strlen(encoded_token) + 1); + *creds = (char *) moz_xmalloc(kNegotiateLen + 1 + strlen(encoded_token) + 1); if (MOZ_UNLIKELY(!*creds)) rv = NS_ERROR_OUT_OF_MEMORY; else @@ -368,7 +368,7 @@ nsHttpNegotiateAuth::TestPref(nsIURI *uri, const char *pref) start = end + 1; } - nsMemory::Free(hostList); + free(hostList); return false; } diff --git a/extensions/gio/nsGIOProtocolHandler.cpp b/extensions/gio/nsGIOProtocolHandler.cpp index 83a8d150ddc..d066e01ca4d 100644 --- a/extensions/gio/nsGIOProtocolHandler.cpp +++ b/extensions/gio/nsGIOProtocolHandler.cpp @@ -875,8 +875,8 @@ mount_operation_ask_password (GMountOperation *mount_op, /* GIO should accept UTF8 */ g_mount_operation_set_username(mount_op, NS_ConvertUTF16toUTF8(user).get()); g_mount_operation_set_password(mount_op, NS_ConvertUTF16toUTF8(pass).get()); - nsMemory::Free(user); - nsMemory::Free(pass); + free(user); + free(pass); g_mount_operation_reply(mount_op, G_MOUNT_OPERATION_HANDLED); } diff --git a/extensions/spellcheck/hunspell/src/mozHunspell.cpp b/extensions/spellcheck/hunspell/src/mozHunspell.cpp index 65b78232bbd..d3caea669e8 100644 --- a/extensions/spellcheck/hunspell/src/mozHunspell.cpp +++ b/extensions/spellcheck/hunspell/src/mozHunspell.cpp @@ -509,7 +509,7 @@ nsresult mozHunspell::ConvertCharset(const char16_t* aStr, char ** aDst) nsresult rv = mEncoder->GetMaxLength(aStr, inLength, &outLength); NS_ENSURE_SUCCESS(rv, rv); - *aDst = (char *) nsMemory::Alloc(sizeof(char) * (outLength+1)); + *aDst = (char *) moz_xmalloc(sizeof(char) * (outLength+1)); NS_ENSURE_TRUE(*aDst, NS_ERROR_OUT_OF_MEMORY); rv = mEncoder->Convert(aStr, &inLength, *aDst, &outLength); @@ -557,7 +557,7 @@ NS_IMETHODIMP mozHunspell::Suggest(const char16_t *aWord, char16_t ***aSuggestio *aSuggestionCount = mHunspell->suggest(&wlst, charsetWord); if (*aSuggestionCount) { - *aSuggestions = (char16_t **)nsMemory::Alloc(*aSuggestionCount * sizeof(char16_t *)); + *aSuggestions = (char16_t **)moz_xmalloc(*aSuggestionCount * sizeof(char16_t *)); if (*aSuggestions) { uint32_t index = 0; for (index = 0; index < *aSuggestionCount && NS_SUCCEEDED(rv); ++index) { @@ -567,7 +567,7 @@ NS_IMETHODIMP mozHunspell::Suggest(const char16_t *aWord, char16_t ***aSuggestio rv = mDecoder->GetMaxLength(wlst[index], inLength, &outLength); if (NS_SUCCEEDED(rv)) { - (*aSuggestions)[index] = (char16_t *) nsMemory::Alloc(sizeof(char16_t) * (outLength+1)); + (*aSuggestions)[index] = (char16_t *) moz_xmalloc(sizeof(char16_t) * (outLength+1)); if ((*aSuggestions)[index]) { rv = mDecoder->Convert(wlst[index], &inLength, (*aSuggestions)[index], &outLength); diff --git a/extensions/spellcheck/src/mozEnglishWordUtils.cpp b/extensions/spellcheck/src/mozEnglishWordUtils.cpp index 5b8cee2d0dc..caae9ff4ae0 100644 --- a/extensions/spellcheck/src/mozEnglishWordUtils.cpp +++ b/extensions/spellcheck/src/mozEnglishWordUtils.cpp @@ -62,7 +62,7 @@ NS_IMETHODIMP mozEnglishWordUtils::GetRootForm(const char16_t *aWord, uint32_t t { case HuhCap: case NoCap: - tmpPtr = (char16_t **)nsMemory::Alloc(sizeof(char16_t *)); + tmpPtr = (char16_t **)moz_xmalloc(sizeof(char16_t *)); if (!tmpPtr) return NS_ERROR_OUT_OF_MEMORY; tmpPtr[0] = ToNewUnicode(word); @@ -76,7 +76,7 @@ NS_IMETHODIMP mozEnglishWordUtils::GetRootForm(const char16_t *aWord, uint32_t t case AllCap: - tmpPtr = (char16_t **)nsMemory::Alloc(sizeof(char16_t *) * 3); + tmpPtr = (char16_t **)moz_xmalloc(sizeof(char16_t *) * 3); if (!tmpPtr) return NS_ERROR_OUT_OF_MEMORY; tmpPtr[0] = ToNewUnicode(word); @@ -105,7 +105,7 @@ NS_IMETHODIMP mozEnglishWordUtils::GetRootForm(const char16_t *aWord, uint32_t t break; case InitCap: - tmpPtr = (char16_t **)nsMemory::Alloc(sizeof(char16_t *) * 2); + tmpPtr = (char16_t **)moz_xmalloc(sizeof(char16_t *) * 2); if (!tmpPtr) return NS_ERROR_OUT_OF_MEMORY; @@ -214,21 +214,21 @@ mozEnglishWordUtils::captype(const nsString &word) char16_t* lword=ToNewUnicode(word); ToUpperCase(lword,lword,word.Length()); if(word.Equals(lword)){ - nsMemory::Free(lword); + free(lword); return AllCap; } ToLowerCase(lword,lword,word.Length()); if(word.Equals(lword)){ - nsMemory::Free(lword); + free(lword); return NoCap; } int32_t length=word.Length(); if(Substring(word,1,length-1).Equals(lword+1)){ - nsMemory::Free(lword); + free(lword); return InitCap; } - nsMemory::Free(lword); + free(lword); return HuhCap; } @@ -240,14 +240,14 @@ NS_IMETHODIMP mozEnglishWordUtils::FromRootForm(const char16_t *aWord, const cha nsresult rv = NS_OK; int32_t length; - char16_t **tmpPtr = (char16_t **)nsMemory::Alloc(sizeof(char16_t *)*icount); + char16_t **tmpPtr = (char16_t **)moz_xmalloc(sizeof(char16_t *)*icount); if (!tmpPtr) return NS_ERROR_OUT_OF_MEMORY; mozEnglishWordUtils::myspCapitalization ct = captype(word); for(uint32_t i = 0; i < icount; ++i) { length = NS_strlen(iwords[i]); - tmpPtr[i] = (char16_t *) nsMemory::Alloc(sizeof(char16_t) * (length + 1)); + tmpPtr[i] = (char16_t *) moz_xmalloc(sizeof(char16_t) * (length + 1)); if (MOZ_UNLIKELY(!tmpPtr[i])) { NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(i, tmpPtr); return NS_ERROR_OUT_OF_MEMORY; diff --git a/gfx/src/nsThebesFontEnumerator.cpp b/gfx/src/nsThebesFontEnumerator.cpp index 12739c280e6..86a592de077 100644 --- a/gfx/src/nsThebesFontEnumerator.cpp +++ b/gfx/src/nsThebesFontEnumerator.cpp @@ -65,7 +65,7 @@ nsThebesFontEnumerator::EnumerateFonts(const char *aLangGroup, } char16_t **fs = static_cast - (nsMemory::Alloc(fontList.Length() * sizeof(char16_t*))); + (moz_xmalloc(fontList.Length() * sizeof(char16_t*))); for (uint32_t i = 0; i < fontList.Length(); i++) { fs[i] = ToNewUnicode(fontList[i]); } diff --git a/image/decoders/nsPNGDecoder.cpp b/image/decoders/nsPNGDecoder.cpp index 2833cb42bbf..cc7f4a4204d 100644 --- a/image/decoders/nsPNGDecoder.cpp +++ b/image/decoders/nsPNGDecoder.cpp @@ -126,10 +126,10 @@ nsPNGDecoder::~nsPNGDecoder() png_destroy_read_struct(&mPNG, mInfo ? &mInfo : nullptr, nullptr); } if (mCMSLine) { - nsMemory::Free(mCMSLine); + free(mCMSLine); } if (interlacebuf) { - nsMemory::Free(interlacebuf); + free(interlacebuf); } if (mInProfile) { qcms_profile_release(mInProfile); diff --git a/intl/locale/nsLocale.cpp b/intl/locale/nsLocale.cpp index e113dc587be..5cf90186621 100644 --- a/intl/locale/nsLocale.cpp +++ b/intl/locale/nsLocale.cpp @@ -60,13 +60,13 @@ nsLocale::AddCategory(const nsAString &category, const nsAString &value) char16_t* newValue = ToNewUnicode(value); if (!newValue) { - nsMemory::Free(newKey); + free(newKey); return NS_ERROR_OUT_OF_MEMORY; } if (!PL_HashTableAdd(fHashtable, newKey, newValue)) { - nsMemory::Free(newKey); - nsMemory::Free(newValue); + free(newKey); + free(newValue); return NS_ERROR_OUT_OF_MEMORY; } @@ -100,8 +100,8 @@ int nsLocale::Hash_EnumerateDelete(PLHashEntry *he, int hashIndex, void *arg) { // delete an entry - nsMemory::Free((char16_t *)he->key); - nsMemory::Free((char16_t *)he->value); + free((char16_t *)he->key); + free((char16_t *)he->value); return (HT_ENUMERATE_NEXT | HT_ENUMERATE_REMOVE); } diff --git a/intl/strres/nsStringBundle.cpp b/intl/strres/nsStringBundle.cpp index 5b003157d32..3d8c1ff33ac 100644 --- a/intl/strres/nsStringBundle.cpp +++ b/intl/strres/nsStringBundle.cpp @@ -751,7 +751,7 @@ done: if (argCount > 1) { for (i = 0; i < argCount; i++) { if (argArray[i]) - nsMemory::Free(argArray[i]); + free(argArray[i]); } } return rv; diff --git a/intl/uconv/nsIUnicodeEncoder.h b/intl/uconv/nsIUnicodeEncoder.h index 3bdafb0e27a..89d333c15d5 100644 --- a/intl/uconv/nsIUnicodeEncoder.h +++ b/intl/uconv/nsIUnicodeEncoder.h @@ -62,7 +62,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIUnicharEncoder, NS_IUNICHARENCODER_IID) if (e \ && NS_SUCCEEDED((e)->GetMaxLength((s), (l), &(al)))\ && ((al) > (int32_t)(sbl)) \ - && (nullptr!=((p)=(char*)nsMemory::Alloc((al)+1))) \ + && (nullptr!=((p)=(char*)moz_xmalloc((al)+1))) \ ) { \ } \ else { \ @@ -77,7 +77,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIUnicharEncoder, NS_IUNICHARENCODER_IID) #define ENCODER_BUFFER_FREE_IF_NEEDED(p,sb) \ PR_BEGIN_MACRO \ if ((p) != (char*)(sb)) \ - nsMemory::Free(p); \ + free(p); \ PR_END_MACRO /** diff --git a/intl/unicharutil/nsSaveAsCharset.cpp b/intl/unicharutil/nsSaveAsCharset.cpp index b8916a89106..34abd6f41e6 100644 --- a/intl/unicharutil/nsSaveAsCharset.cpp +++ b/intl/unicharutil/nsSaveAsCharset.cpp @@ -96,7 +96,7 @@ nsSaveAsCharset::Convert(const char16_t *inString, char **_retval) rv = mEntityConverter->ConvertToEntities(inString, mEntityVersion, &entity); if(NS_SUCCEEDED(rv)) { rv = DoCharsetConversion(entity, _retval); - nsMemory::Free(entity); + free(entity); } } else @@ -287,7 +287,7 @@ nsSaveAsCharset::DoConversionFallBack(uint32_t inUCS4, char *outString, int32_t return NS_ERROR_OUT_OF_MEMORY; } PL_strcpy(outString, entity); - nsMemory::Free(entity); + free(entity); return rv; } } diff --git a/intl/unicharutil/nsUnicodeNormalizer.cpp b/intl/unicharutil/nsUnicodeNormalizer.cpp index 702386012a6..16c3a969c59 100644 --- a/intl/unicharutil/nsUnicodeNormalizer.cpp +++ b/intl/unicharutil/nsUnicodeNormalizer.cpp @@ -576,8 +576,8 @@ workbuf_init(workbuf_t *wb) { static void workbuf_free(workbuf_t *wb) { if (wb->ucs != wb->ucs_buf) { - nsMemory::Free(wb->ucs); - nsMemory::Free(wb->cclass); + free(wb->ucs); + free(wb->cclass); } } @@ -586,21 +586,21 @@ workbuf_extend(workbuf_t *wb) { int32_t newsize = wb->size * 3; if (wb->ucs == wb->ucs_buf) { - wb->ucs = (uint32_t*)nsMemory::Alloc(sizeof(wb->ucs[0]) * newsize); + wb->ucs = (uint32_t*)moz_xmalloc(sizeof(wb->ucs[0]) * newsize); if (!wb->ucs) return NS_ERROR_OUT_OF_MEMORY; - wb->cclass = (int32_t*)nsMemory::Alloc(sizeof(wb->cclass[0]) * newsize); + wb->cclass = (int32_t*)moz_xmalloc(sizeof(wb->cclass[0]) * newsize); if (!wb->cclass) { - nsMemory::Free(wb->ucs); + free(wb->ucs); wb->ucs = nullptr; return NS_ERROR_OUT_OF_MEMORY; } } else { - void* buf = nsMemory::Realloc(wb->ucs, sizeof(wb->ucs[0]) * newsize); + void* buf = moz_xrealloc(wb->ucs, sizeof(wb->ucs[0]) * newsize); if (!buf) return NS_ERROR_OUT_OF_MEMORY; wb->ucs = (uint32_t*)buf; - buf = nsMemory::Realloc(wb->cclass, sizeof(wb->cclass[0]) * newsize); + buf = moz_xrealloc(wb->cclass, sizeof(wb->cclass[0]) * newsize); if (!buf) return NS_ERROR_OUT_OF_MEMORY; wb->cclass = (int32_t*)buf; diff --git a/intl/unicharutil/tests/UnicharSelfTest.cpp b/intl/unicharutil/tests/UnicharSelfTest.cpp index f2e37f1d670..d9bbd3b99c7 100644 --- a/intl/unicharutil/tests/UnicharSelfTest.cpp +++ b/intl/unicharutil/tests/UnicharSelfTest.cpp @@ -507,7 +507,7 @@ static void TestEntityConversion(uint32_t version) res = entityConv->ConvertToEntity(data[i], version, &entity); if (NS_SUCCEEDED(res) && entity) { printf("%c %s\n", data[i], entity); - nsMemory::Free(entity); + free(entity); } } @@ -520,7 +520,7 @@ static void TestEntityConversion(uint32_t version) if (';' == (char) *centity) printf("\n"); } - nsMemory::Free(entities); + free(entities); } printf("==============================\n"); @@ -560,7 +560,7 @@ static void TestSaveAsCharset() res = saveAsCharset->Convert(inString.get(), &outString); if (NS_FAILED(res)) {printf("\tFailed!! return value != NS_OK\n");} if (!outString) {printf("\tFailed!! output null\n");} - else {printf("%s\n", outString); nsMemory::Free(outString);} + else {printf("%s\n", outString); free(outString);} printf("ISO-2022-JP attr_plainTextDefault entityNone\n"); res = saveAsCharset->Init("ISO-2022-JP", @@ -570,11 +570,11 @@ static void TestSaveAsCharset() res = saveAsCharset->Convert(inString.get(), &outString); if (NS_FAILED(res)) {printf("\tFailed!! return value != NS_OK\n");} if (!outString) {printf("\tFailed!! output null\n");} - else {printf("%s\n", outString); nsMemory::Free(outString);} + else {printf("%s\n", outString); free(outString);} if (NS_ERROR_UENC_NOMAPPING == res) { outString = ToNewUTF8String(inString); if (!outString) {printf("\tFailed!! output null\n");} - else {printf("Fall back to UTF-8: %s\n", outString); nsMemory::Free(outString);} + else {printf("Fall back to UTF-8: %s\n", outString); free(outString);} } printf("ISO-2022-JP attr_FallbackQuestionMark entityNone\n"); @@ -585,7 +585,7 @@ static void TestSaveAsCharset() res = saveAsCharset->Convert(inString.get(), &outString); if (NS_FAILED(res)) {printf("\tFailed!! return value != NS_OK\n");} if (!outString) {printf("\tFailed!! output null\n");} - else {printf("%s\n", outString); nsMemory::Free(outString);} + else {printf("%s\n", outString); free(outString);} printf("ISO-2022-JP attr_FallbackEscapeU entityNone\n"); res = saveAsCharset->Init("ISO-2022-JP", @@ -595,7 +595,7 @@ static void TestSaveAsCharset() res = saveAsCharset->Convert(inString.get(), &outString); if (NS_FAILED(res)) {printf("\tFailed!! return value != NS_OK\n");} if (!outString) {printf("\tFailed!! output null\n");} - else {printf("%s\n", outString); nsMemory::Free(outString);} + else {printf("%s\n", outString); free(outString);} printf("ISO-8859-1 attr_htmlTextDefault html40Latin1\n"); res = saveAsCharset->Init("ISO-8859-1", @@ -605,7 +605,7 @@ static void TestSaveAsCharset() res = saveAsCharset->Convert(inString.get(), &outString); if (NS_ERROR_UENC_NOMAPPING != res && NS_FAILED(res)) {printf("\tFailed!! return value != NS_OK\n");} if (!outString) {printf("\tFailed!! output null\n");} - else {printf("%s\n", outString); nsMemory::Free(outString);} + else {printf("%s\n", outString); free(outString);} printf("ISO-8859-1 attr_FallbackHexNCR+attr_EntityAfterCharsetConv html40Latin1 \n"); res = saveAsCharset->Init("ISO-8859-1", @@ -616,7 +616,7 @@ static void TestSaveAsCharset() res = saveAsCharset->Convert(inString.get(), &outString); if (NS_ERROR_UENC_NOMAPPING != res && NS_FAILED(res)) {printf("\tFailed!! return value != NS_OK\n");} if (!outString) {printf("\tFailed!! output null\n");} - else {printf("%s\n", outString); nsMemory::Free(outString);} + else {printf("%s\n", outString); free(outString);} printf("==============================\n"); diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index 564e24607eb..f31f8dfdd2a 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -127,7 +127,7 @@ nsXPCComponents_Interfaces::GetInterfaces(uint32_t* aCount, nsIID * **aArray) const uint32_t count = 2; *aCount = count; nsIID** array; - *aArray = array = static_cast(nsMemory::Alloc(count * sizeof(nsIID*))); + *aArray = array = static_cast(moz_xmalloc(count * sizeof(nsIID*))); if (!array) return NS_ERROR_OUT_OF_MEMORY; @@ -147,8 +147,8 @@ nsXPCComponents_Interfaces::GetInterfaces(uint32_t* aCount, nsIID * **aArray) return NS_OK; oom: while (index) - nsMemory::Free(array[--index]); - nsMemory::Free(array); + free(array[--index]); + free(array); *aArray = nullptr; return NS_ERROR_OUT_OF_MEMORY; } @@ -362,7 +362,7 @@ nsXPCComponents_InterfacesByID::GetInterfaces(uint32_t* aCount, nsIID * **aArray const uint32_t count = 2; *aCount = count; nsIID** array; - *aArray = array = static_cast(nsMemory::Alloc(count * sizeof(nsIID*))); + *aArray = array = static_cast(moz_xmalloc(count * sizeof(nsIID*))); if (!array) return NS_ERROR_OUT_OF_MEMORY; @@ -382,8 +382,8 @@ nsXPCComponents_InterfacesByID::GetInterfaces(uint32_t* aCount, nsIID * **aArray return NS_OK; oom: while (index) - nsMemory::Free(array[--index]); - nsMemory::Free(array); + free(array[--index]); + free(array); *aArray = nullptr; return NS_ERROR_OUT_OF_MEMORY; } @@ -599,7 +599,7 @@ nsXPCComponents_Classes::GetInterfaces(uint32_t* aCount, nsIID * **aArray) const uint32_t count = 2; *aCount = count; nsIID** array; - *aArray = array = static_cast(nsMemory::Alloc(count * sizeof(nsIID*))); + *aArray = array = static_cast(moz_xmalloc(count * sizeof(nsIID*))); if (!array) return NS_ERROR_OUT_OF_MEMORY; @@ -619,8 +619,8 @@ nsXPCComponents_Classes::GetInterfaces(uint32_t* aCount, nsIID * **aArray) return NS_OK; oom: while (index) - nsMemory::Free(array[--index]); - nsMemory::Free(array); + free(array[--index]); + free(array); *aArray = nullptr; return NS_ERROR_OUT_OF_MEMORY; } @@ -816,7 +816,7 @@ nsXPCComponents_ClassesByID::GetInterfaces(uint32_t* aCount, nsIID * **aArray) const uint32_t count = 2; *aCount = count; nsIID** array; - *aArray = array = static_cast(nsMemory::Alloc(count * sizeof(nsIID*))); + *aArray = array = static_cast(moz_xmalloc(count * sizeof(nsIID*))); if (!array) return NS_ERROR_OUT_OF_MEMORY; @@ -836,8 +836,8 @@ nsXPCComponents_ClassesByID::GetInterfaces(uint32_t* aCount, nsIID * **aArray) return NS_OK; oom: while (index) - nsMemory::Free(array[--index]); - nsMemory::Free(array); + free(array[--index]); + free(array); *aArray = nullptr; return NS_ERROR_OUT_OF_MEMORY; } @@ -1056,7 +1056,7 @@ nsXPCComponents_Results::GetInterfaces(uint32_t* aCount, nsIID * **aArray) const uint32_t count = 2; *aCount = count; nsIID** array; - *aArray = array = static_cast(nsMemory::Alloc(count * sizeof(nsIID*))); + *aArray = array = static_cast(moz_xmalloc(count * sizeof(nsIID*))); if (!array) return NS_ERROR_OUT_OF_MEMORY; @@ -1076,8 +1076,8 @@ nsXPCComponents_Results::GetInterfaces(uint32_t* aCount, nsIID * **aArray) return NS_OK; oom: while (index) - nsMemory::Free(array[--index]); - nsMemory::Free(array); + free(array[--index]); + free(array); *aArray = nullptr; return NS_ERROR_OUT_OF_MEMORY; } @@ -1253,7 +1253,7 @@ nsXPCComponents_ID::GetInterfaces(uint32_t* aCount, nsIID * **aArray) const uint32_t count = 2; *aCount = count; nsIID** array; - *aArray = array = static_cast(nsMemory::Alloc(count * sizeof(nsIID*))); + *aArray = array = static_cast(moz_xmalloc(count * sizeof(nsIID*))); if (!array) return NS_ERROR_OUT_OF_MEMORY; @@ -1273,8 +1273,8 @@ nsXPCComponents_ID::GetInterfaces(uint32_t* aCount, nsIID * **aArray) return NS_OK; oom: while (index) - nsMemory::Free(array[--index]); - nsMemory::Free(array); + free(array[--index]); + free(array); *aArray = nullptr; return NS_ERROR_OUT_OF_MEMORY; } @@ -1461,7 +1461,7 @@ nsXPCComponents_Exception::GetInterfaces(uint32_t* aCount, nsIID * **aArray) const uint32_t count = 2; *aCount = count; nsIID** array; - *aArray = array = static_cast(nsMemory::Alloc(count * sizeof(nsIID*))); + *aArray = array = static_cast(moz_xmalloc(count * sizeof(nsIID*))); if (!array) return NS_ERROR_OUT_OF_MEMORY; @@ -1481,8 +1481,8 @@ nsXPCComponents_Exception::GetInterfaces(uint32_t* aCount, nsIID * **aArray) return NS_OK; oom: while (index) - nsMemory::Free(array[--index]); - nsMemory::Free(array); + free(array[--index]); + free(array); *aArray = nullptr; return NS_ERROR_OUT_OF_MEMORY; } @@ -1842,7 +1842,7 @@ nsXPCConstructor::GetInterfaces(uint32_t* aCount, nsIID * **aArray) const uint32_t count = 2; *aCount = count; nsIID** array; - *aArray = array = static_cast(nsMemory::Alloc(count * sizeof(nsIID*))); + *aArray = array = static_cast(moz_xmalloc(count * sizeof(nsIID*))); if (!array) return NS_ERROR_OUT_OF_MEMORY; @@ -1862,8 +1862,8 @@ nsXPCConstructor::GetInterfaces(uint32_t* aCount, nsIID * **aArray) return NS_OK; oom: while (index) - nsMemory::Free(array[--index]); - nsMemory::Free(array); + free(array[--index]); + free(array); *aArray = nullptr; return NS_ERROR_OUT_OF_MEMORY; } @@ -1930,7 +1930,7 @@ nsXPCConstructor::nsXPCConstructor(nsIJSCID* aClassID, nsXPCConstructor::~nsXPCConstructor() { if (mInitializer) - nsMemory::Free(mInitializer); + free(mInitializer); } /* readonly attribute nsIJSCID classID; */ @@ -2088,7 +2088,7 @@ nsXPCComponents_Constructor::GetInterfaces(uint32_t* aCount, nsIID * **aArray) const uint32_t count = 2; *aCount = count; nsIID** array; - *aArray = array = static_cast(nsMemory::Alloc(count * sizeof(nsIID*))); + *aArray = array = static_cast(moz_xmalloc(count * sizeof(nsIID*))); if (!array) return NS_ERROR_OUT_OF_MEMORY; @@ -2108,8 +2108,8 @@ nsXPCComponents_Constructor::GetInterfaces(uint32_t* aCount, nsIID * **aArray) return NS_OK; oom: while (index) - nsMemory::Free(array[--index]); - nsMemory::Free(array); + free(array[--index]); + free(array); *aArray = nullptr; return NS_ERROR_OUT_OF_MEMORY; } diff --git a/js/xpconnect/src/XPCConvert.cpp b/js/xpconnect/src/XPCConvert.cpp index ec56fb795ee..7708420a430 100644 --- a/js/xpconnect/src/XPCConvert.cpp +++ b/js/xpconnect/src/XPCConvert.cpp @@ -565,7 +565,7 @@ XPCConvert::JSData2Native(void* d, HandleValue s, if (length == size_t(-1)) { return false; } - char* buffer = static_cast(nsMemory::Alloc(length + 1)); + char* buffer = static_cast(moz_xmalloc(length + 1)); if (!buffer) { return false; } @@ -589,7 +589,7 @@ XPCConvert::JSData2Native(void* d, HandleValue s, } int len = JS_GetStringLength(str); int byte_len = (len+1)*sizeof(char16_t); - if (!(*((void**)d) = nsMemory::Alloc(byte_len))) { + if (!(*((void**)d) = moz_xmalloc(byte_len))) { // XXX should report error return false; } @@ -1356,7 +1356,7 @@ CheckTargetAndPopulate(const nsXPTType& type, // This could overflow on 32-bit systems so check max first. size_t byteSize = count * typeSize; - if (count > max || !(*output = nsMemory::Alloc(byteSize))) { + if (count > max || !(*output = moz_xmalloc(byteSize))) { if (pErr) *pErr = NS_ERROR_OUT_OF_MEMORY; @@ -1541,7 +1541,7 @@ XPCConvert::JSArray2Native(void** d, HandleValue s, cleanupMode = _mode; \ size_t max = UINT32_MAX / sizeof(_t); \ if (count > max || \ - nullptr == (array = nsMemory::Alloc(count * sizeof(_t)))) { \ + nullptr == (array = moz_xmalloc(count * sizeof(_t)))) { \ if (pErr) \ *pErr = NS_ERROR_OUT_OF_MEMORY; \ goto failure; \ @@ -1611,10 +1611,10 @@ failure: void** a = (void**) array; for (uint32_t i = 0; i < initedCount; i++) { void* p = a[i]; - if (p) nsMemory::Free(p); + if (p) free(p); } } - nsMemory::Free(array); + free(array); } return false; @@ -1691,7 +1691,7 @@ XPCConvert::JSStringWithSize2Native(void* d, HandleValue s, } if (0 != count) { len = (count + 1) * sizeof(char); - if (!(*((void**)d) = nsMemory::Alloc(len))) + if (!(*((void**)d) = moz_xmalloc(len))) return false; return true; } @@ -1721,7 +1721,7 @@ XPCConvert::JSStringWithSize2Native(void* d, HandleValue s, len = count; uint32_t alloc_len = (len + 1) * sizeof(char); - char* buffer = static_cast(nsMemory::Alloc(alloc_len)); + char* buffer = static_cast(moz_xmalloc(alloc_len)); if (!buffer) { return false; } @@ -1745,7 +1745,7 @@ XPCConvert::JSStringWithSize2Native(void* d, HandleValue s, if (0 != count) { len = (count + 1) * sizeof(char16_t); - if (!(*((void**)d) = nsMemory::Alloc(len))) + if (!(*((void**)d) = moz_xmalloc(len))) return false; return true; } @@ -1769,7 +1769,7 @@ XPCConvert::JSStringWithSize2Native(void* d, HandleValue s, len = count; uint32_t alloc_len = (len + 1) * sizeof(char16_t); - if (!(*((void**)d) = nsMemory::Alloc(alloc_len))) { + if (!(*((void**)d) = moz_xmalloc(alloc_len))) { // XXX should report error return false; } diff --git a/js/xpconnect/src/XPCJSID.cpp b/js/xpconnect/src/XPCJSID.cpp index 178ca33dff7..15e333917ee 100644 --- a/js/xpconnect/src/XPCJSID.cpp +++ b/js/xpconnect/src/XPCJSID.cpp @@ -599,7 +599,7 @@ nsJSCID::NewID(const char* str) if (NS_FAILED(registrar->ContractIDToCID(str, &cid))) return nullptr; bool success = idObj->mDetails->InitWithName(*cid, str); - nsMemory::Free(cid); + free(cid); if (!success) return nullptr; } diff --git a/js/xpconnect/src/XPCRuntimeService.cpp b/js/xpconnect/src/XPCRuntimeService.cpp index 239851fa972..cf5acac413f 100644 --- a/js/xpconnect/src/XPCRuntimeService.cpp +++ b/js/xpconnect/src/XPCRuntimeService.cpp @@ -87,7 +87,7 @@ BackstagePass::GetInterfaces(uint32_t* aCount, nsIID * **aArray) const uint32_t count = 2; *aCount = count; nsIID** array; - *aArray = array = static_cast(nsMemory::Alloc(count * sizeof(nsIID*))); + *aArray = array = static_cast(moz_xmalloc(count * sizeof(nsIID*))); if (!array) return NS_ERROR_OUT_OF_MEMORY; @@ -107,8 +107,8 @@ BackstagePass::GetInterfaces(uint32_t* aCount, nsIID * **aArray) return NS_OK; oom: while (index) - nsMemory::Free(array[--index]); - nsMemory::Free(array); + free(array[--index]); + free(array); *aArray = nullptr; return NS_ERROR_OUT_OF_MEMORY; } diff --git a/js/xpconnect/src/XPCVariant.cpp b/js/xpconnect/src/XPCVariant.cpp index ec217ff68a5..fbd24ba9e77 100644 --- a/js/xpconnect/src/XPCVariant.cpp +++ b/js/xpconnect/src/XPCVariant.cpp @@ -494,7 +494,7 @@ XPCVariant::VariantDataToJS(nsIVariant* variant, return false; bool success = XPCConvert::NativeData2JS(pJSVal, (const void*)&pc, TD_PSTRING, &iid, pErr); - nsMemory::Free(pc); + free(pc); return success; } case nsIDataType::VTYPE_STRING_SIZE_IS: @@ -505,7 +505,7 @@ XPCVariant::VariantDataToJS(nsIVariant* variant, return false; bool success = XPCConvert::NativeStringWithSize2JS(pJSVal, (const void*)&pc, TD_PSTRING_SIZE_IS, size, pErr); - nsMemory::Free(pc); + free(pc); return success; } case nsIDataType::VTYPE_WCHAR_STR: @@ -515,7 +515,7 @@ XPCVariant::VariantDataToJS(nsIVariant* variant, return false; bool success = XPCConvert::NativeData2JS(pJSVal, (const void*)&pwc, TD_PSTRING, &iid, pErr); - nsMemory::Free(pwc); + free(pwc); return success; } case nsIDataType::VTYPE_WSTRING_SIZE_IS: @@ -526,7 +526,7 @@ XPCVariant::VariantDataToJS(nsIVariant* variant, return false; bool success = XPCConvert::NativeStringWithSize2JS(pJSVal, (const void*)&pwc, TD_PWSTRING_SIZE_IS, size, pErr); - nsMemory::Free(pwc); + free(pwc); return success; } case nsIDataType::VTYPE_INTERFACE: @@ -538,7 +538,7 @@ XPCVariant::VariantDataToJS(nsIVariant* variant, return false; iid = *piid; - nsMemory::Free((char*)piid); + free((char*)piid); bool success = XPCConvert::NativeData2JS(pJSVal, (const void*)&pi, TD_INTERFACE_IS_TYPE, &iid, pErr); diff --git a/js/xpconnect/src/XPCWrappedJS.cpp b/js/xpconnect/src/XPCWrappedJS.cpp index 549b114ec04..c28b2fc8ea6 100644 --- a/js/xpconnect/src/XPCWrappedJS.cpp +++ b/js/xpconnect/src/XPCWrappedJS.cpp @@ -631,7 +631,7 @@ nsXPCWrappedJS::DebugDump(int16_t depth) GetClass()->GetInterfaceInfo()->GetName(&name); XPC_LOG_ALWAYS(("interface name is %s", name)); if (name) - nsMemory::Free(name); + free(name); char * iid = GetClass()->GetIID().ToString(); XPC_LOG_ALWAYS(("IID number is %s", iid ? iid : "invalid")); if (iid) diff --git a/js/xpconnect/src/XPCWrappedJSClass.cpp b/js/xpconnect/src/XPCWrappedJSClass.cpp index d5fde8ea941..13de97fba96 100644 --- a/js/xpconnect/src/XPCWrappedJSClass.cpp +++ b/js/xpconnect/src/XPCWrappedJSClass.cpp @@ -172,7 +172,7 @@ nsXPCWrappedJSClass::~nsXPCWrappedJSClass() mRuntime->GetWrappedJSClassMap()->Remove(this); if (mName) - nsMemory::Free(mName); + free(mName); } JSObject* @@ -690,7 +690,7 @@ nsXPCWrappedJSClass::CleanupPointerArray(const nsXPTType& datum_type, void** pp = (void**) arrayp; for (uint32_t k = 0; k < array_count; k++) { void* p = pp[k]; - if (p) nsMemory::Free(p); + if (p) free(p); } } } @@ -705,7 +705,7 @@ nsXPCWrappedJSClass::CleanupPointerTypeObject(const nsXPTType& type, if (p) p->Release(); } else { void* p = *((void**)pp); - if (p) nsMemory::Free(p); + if (p) free(p); } } @@ -1178,7 +1178,7 @@ pre_call_clean_up: } // always release the array if it is inout - nsMemory::Free(pp); + free(pp); } } else CleanupPointerTypeObject(type, (void**)p); @@ -1418,7 +1418,7 @@ pre_call_clean_up: CleanupPointerArray(datum_type, array_count, pp); } - nsMemory::Free(pp); + free(pp); } } else CleanupPointerTypeObject(type, (void**)p); @@ -1486,7 +1486,7 @@ nsXPCWrappedJSClass::DebugDump(int16_t depth) mInfo->GetName(&name); XPC_LOG_ALWAYS(("interface name is %s", name)); if (name) - nsMemory::Free(name); + free(name); char * iid = mIID.ToString(); XPC_LOG_ALWAYS(("IID number is %s", iid ? iid : "invalid")); if (iid) diff --git a/js/xpconnect/src/XPCWrappedNative.cpp b/js/xpconnect/src/XPCWrappedNative.cpp index fbd8d1ef023..84896475360 100644 --- a/js/xpconnect/src/XPCWrappedNative.cpp +++ b/js/xpconnect/src/XPCWrappedNative.cpp @@ -1467,7 +1467,7 @@ CallMethodHelper::~CallMethodHelper() } // always free the array itself - nsMemory::Free(p); + free(p); } else { // Clean up single parameters (if requested). if (dp->DoesValNeedCleanup()) @@ -2034,7 +2034,7 @@ CallMethodHelper::CleanupParam(nsXPTCMiniVariant& param, nsXPTType& type) break; default: MOZ_ASSERT(!type.IsArithmetic(), "Cleanup requested on unexpected type."); - nsMemory::Free(param.val.p); + free(param.val.p); break; } } @@ -2320,9 +2320,9 @@ static void DEBUG_CheckClassInfoClaims(XPCWrappedNative* wrapper) interfaceName); if (className) - nsMemory::Free(className); + free(className); if (contractID) - nsMemory::Free(contractID); + free(contractID); } } #endif diff --git a/js/xpconnect/src/nsScriptError.cpp b/js/xpconnect/src/nsScriptError.cpp index 374d91cf2e9..887c61b5126 100644 --- a/js/xpconnect/src/nsScriptError.cpp +++ b/js/xpconnect/src/nsScriptError.cpp @@ -227,11 +227,11 @@ nsScriptError::ToString(nsACString& /*UTF8*/ aResult) tempMessage); if (nullptr != tempMessage) - nsMemory::Free(tempMessage); + free(tempMessage); if (nullptr != tempSourceName) - nsMemory::Free(tempSourceName); + free(tempSourceName); if (nullptr != tempSourceLine) - nsMemory::Free(tempSourceLine); + free(tempSourceLine); if (!temp) return NS_ERROR_OUT_OF_MEMORY; diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index b4cf1026bfb..d2bdaabe2f3 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -1264,7 +1264,7 @@ ReadScriptOrFunction(nsIObjectInputStream* stream, JSContext* cx, } } - nsMemory::Free(data); + free(data); return rv; } diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index c782263c688..1d4fb6e594b 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -1697,7 +1697,7 @@ public: MOZ_COUNT_CTOR(XPCNativeScriptableShared);} ~XPCNativeScriptableShared() - {if (mJSClass.base.name)nsMemory::Free((void*)mJSClass.base.name); + {if (mJSClass.base.name)free((void*)mJSClass.base.name); MOZ_COUNT_DTOR(XPCNativeScriptableShared);} char* TransferNameOwnership() diff --git a/js/xpconnect/tests/components/native/xpctest_attributes.cpp b/js/xpconnect/tests/components/native/xpctest_attributes.cpp index af79fffb60e..6a844fee228 100644 --- a/js/xpconnect/tests/components/native/xpctest_attributes.cpp +++ b/js/xpconnect/tests/components/native/xpctest_attributes.cpp @@ -71,7 +71,7 @@ xpcTestObjectReadWrite :: xpcTestObjectReadWrite() { xpcTestObjectReadWrite :: ~xpcTestObjectReadWrite() { - nsMemory::Free(stringProperty); + free(stringProperty); } NS_IMETHODIMP xpcTestObjectReadWrite :: GetStringProperty(char * *aStringProperty) { @@ -83,7 +83,7 @@ NS_IMETHODIMP xpcTestObjectReadWrite :: GetStringProperty(char * *aStringPropert } NS_IMETHODIMP xpcTestObjectReadWrite :: SetStringProperty(const char * aStringProperty) { - nsMemory::Free(stringProperty); + free(stringProperty); stringProperty = (char*) nsMemory::Clone(aStringProperty, sizeof(char)*(strlen(aStringProperty)+1)); return NS_OK; diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index fcc16359f75..2eaceabcda8 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -2265,7 +2265,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument, styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, csssheet); shouldOverride = true; } - nsMemory::Free(str); + free(str); } } } diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index dab03987ec5..7317bc86c41 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -10437,7 +10437,7 @@ static void RecurseIndiTotals(nsPresContext* aPresContext, printf("%s - %p [%d][", name, (void*)aParentFrame, counter->mCount); printf("%d", counter->mCounter.GetTotal()); printf("]\n"); - nsMemory::Free(name); + free(name); } nsIFrame* child = aParentFrame->GetFirstPrincipalChild(); @@ -10457,7 +10457,7 @@ int ReflowCountMgr::DoSingleIndi(PLHashEntry *he, int i, void *arg) printf("%s - %p [%d][", name, (void*)counter->mFrame, counter->mCount); printf("%d", counter->mCounter.GetTotal()); printf("]\n"); - nsMemory::Free(name); + free(name); } return HT_ENUMERATE_NEXT; } diff --git a/layout/generic/nsFloatManager.cpp b/layout/generic/nsFloatManager.cpp index fd7d0205207..3f5fe77f7bf 100644 --- a/layout/generic/nsFloatManager.cpp +++ b/layout/generic/nsFloatManager.cpp @@ -66,7 +66,7 @@ void* nsFloatManager::operator new(size_t aSize) CPP_THROW_NEW // The cache is empty, this means we haveto create a new instance using // the global |operator new|. - return nsMemory::Alloc(aSize); + return moz_xmalloc(aSize); } void @@ -89,7 +89,7 @@ nsFloatManager::operator delete(void* aPtr, size_t aSize) // The cache is full, or the layout module has been shut down, // delete this float manager. - nsMemory::Free(aPtr); + free(aPtr); } @@ -104,7 +104,7 @@ void nsFloatManager::Shutdown() for (i = 0; i < sCachedFloatManagerCount; i++) { void* floatManager = sCachedFloatManagers[i]; if (floatManager) - nsMemory::Free(floatManager); + free(floatManager); } // Disable further caching. diff --git a/layout/generic/nsImageMap.cpp b/layout/generic/nsImageMap.cpp index 72de469fa27..cdbc89dcdd1 100644 --- a/layout/generic/nsImageMap.cpp +++ b/layout/generic/nsImageMap.cpp @@ -112,7 +112,7 @@ void Area::ParseCoords(const nsAString& aSpec) mCoords = nullptr; if (*cp == '\0') { - nsMemory::Free(cp); + free(cp); return; } @@ -126,7 +126,7 @@ void Area::ParseCoords(const nsAString& aSpec) } if (*n_str == '\0') { - nsMemory::Free(cp); + free(cp); return; } @@ -211,7 +211,7 @@ void Area::ParseCoords(const nsAString& aSpec) value_list = new nscoord[cnt]; if (!value_list) { - nsMemory::Free(cp); + free(cp); return; } @@ -254,7 +254,7 @@ void Area::ParseCoords(const nsAString& aSpec) mNumCoords = cnt; mCoords = value_list; - nsMemory::Free(cp); + free(cp); } } diff --git a/layout/generic/nsPageFrame.cpp b/layout/generic/nsPageFrame.cpp index 9afcdd65964..208bb2117a8 100644 --- a/layout/generic/nsPageFrame.cpp +++ b/layout/generic/nsPageFrame.cpp @@ -206,7 +206,7 @@ nsPageFrame::ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr) if (aStr.Find(kPageAndTotal) != kNotFound) { char16_t * uStr = nsTextFormatter::smprintf(mPD->mPageNumAndTotalsFormat.get(), mPageNum, mTotNumPages); aNewStr.ReplaceSubstring(kPageAndTotal.get(), uStr); - nsMemory::Free(uStr); + free(uStr); } // Search to see if the page number code is in the string @@ -215,7 +215,7 @@ nsPageFrame::ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr) if (aStr.Find(kPage) != kNotFound) { char16_t * uStr = nsTextFormatter::smprintf(mPD->mPageNumFormat.get(), mPageNum); aNewStr.ReplaceSubstring(kPage.get(), uStr); - nsMemory::Free(uStr); + free(uStr); } NS_NAMED_LITERAL_STRING(kTitle, "&T"); @@ -232,7 +232,7 @@ nsPageFrame::ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr) if (aStr.Find(kPageTotal) != kNotFound) { char16_t * uStr = nsTextFormatter::smprintf(mPD->mPageNumFormat.get(), mTotNumPages); aNewStr.ReplaceSubstring(kPageTotal.get(), uStr); - nsMemory::Free(uStr); + free(uStr); } } diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index 3bf5262da9e..8510bef56d0 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -3879,7 +3879,7 @@ Selection::GetRangesForInterval(nsIDOMNode* aBeginNode, int32_t aBeginOffset, } *aResults = static_cast - (nsMemory::Alloc(sizeof(nsIDOMRange*) * *aResultCount)); + (moz_xmalloc(sizeof(nsIDOMRange*) * *aResultCount)); NS_ENSURE_TRUE(*aResults, NS_ERROR_OUT_OF_MEMORY); for (uint32_t i = 0; i < *aResultCount; i++) { diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 1195f0fec38..6218356436b 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -407,7 +407,7 @@ DestroyUserData(void* aUserData) { TextRunUserData* userData = static_cast(aUserData); if (userData) { - nsMemory::Free(userData); + free(userData); } } @@ -1896,7 +1896,7 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer) dummyData.mMappedFlows = &dummyMappedFlow; } else { userData = static_cast - (nsMemory::Alloc(sizeof(TextRunUserData) + mMappedFlows.Length()*sizeof(TextRunMappedFlow))); + (moz_xmalloc(sizeof(TextRunUserData) + mMappedFlows.Length()*sizeof(TextRunMappedFlow))); userDataToDestroy = userData; userData->mMappedFlows = reinterpret_cast(userData + 1); } @@ -2290,7 +2290,7 @@ BuildTextRunsScanner::SetupLineBreakerContext(gfxTextRun *aTextRun) dummyData.mMappedFlows = &dummyMappedFlow; } else { userData = static_cast - (nsMemory::Alloc(sizeof(TextRunUserData) + mMappedFlows.Length()*sizeof(TextRunMappedFlow))); + (moz_xmalloc(sizeof(TextRunUserData) + mMappedFlows.Length()*sizeof(TextRunMappedFlow))); userDataToDestroy = userData; userData->mMappedFlows = reinterpret_cast(userData + 1); } diff --git a/layout/inspector/inDOMUtils.cpp b/layout/inspector/inDOMUtils.cpp index a1d5473cd33..b0bc0ca5cde 100644 --- a/layout/inspector/inDOMUtils.cpp +++ b/layout/inspector/inDOMUtils.cpp @@ -456,7 +456,7 @@ inDOMUtils::GetCSSPropertyNames(uint32_t aFlags, uint32_t* aCount, } char16_t** props = - static_cast(nsMemory::Alloc(maxCount * sizeof(char16_t*))); + static_cast(moz_xmalloc(maxCount * sizeof(char16_t*))); #define DO_PROP(_prop) \ PR_BEGIN_MACRO \ @@ -616,7 +616,7 @@ inDOMUtils::GetSubpropertiesForCSSProperty(const nsAString& aProperty, nsTArray array; if (!nsCSSProps::IsShorthand(propertyID)) { - *aValues = static_cast(nsMemory::Alloc(sizeof(char16_t*))); + *aValues = static_cast(moz_xmalloc(sizeof(char16_t*))); (*aValues)[0] = ToNewUnicode(nsCSSProps::GetStringValue(propertyID)); *aLength = 1; return NS_OK; @@ -630,7 +630,7 @@ inDOMUtils::GetSubpropertiesForCSSProperty(const nsAString& aProperty, } *aValues = - static_cast(nsMemory::Alloc(subpropCount * sizeof(char16_t*))); + static_cast(moz_xmalloc(subpropCount * sizeof(char16_t*))); *aLength = subpropCount; for (const nsCSSProperty *props = nsCSSProps::SubpropertyEntryFor(propertyID), *props_start = props; diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index 624576dc920..a7cd02548aa 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -899,7 +899,7 @@ nsPrintEngine::EnumerateDocumentNames(uint32_t* aCount, *aResult = nullptr; int32_t numDocs = mPrt->mPrintDocList.Length(); - char16_t** array = (char16_t**) nsMemory::Alloc(numDocs * sizeof(char16_t*)); + char16_t** array = (char16_t**) moz_xmalloc(numDocs * sizeof(char16_t*)); if (!array) return NS_ERROR_OUT_OF_MEMORY; @@ -1453,8 +1453,8 @@ nsPrintEngine::GetDisplayTitleAndURL(nsPrintObject* aPO, aURLStr = docURLStrPS; } - nsMemory::Free(docTitleStrPS); - nsMemory::Free(docURLStrPS); + free(docTitleStrPS); + free(docURLStrPS); } nsAutoString docTitle; @@ -3022,9 +3022,9 @@ void nsPrintEngine::CleanupDocTitleArray(char16_t**& aArray, int32_t& aCount) { for (int32_t i = aCount - 1; i >= 0; i--) { - nsMemory::Free(aArray[i]); + free(aArray[i]); } - nsMemory::Free(aArray); + free(aArray); aArray = nullptr; aCount = 0; } diff --git a/layout/style/nsROCSSPrimitiveValue.cpp b/layout/style/nsROCSSPrimitiveValue.cpp index 4cb438ce28d..e267ed038aa 100644 --- a/layout/style/nsROCSSPrimitiveValue.cpp +++ b/layout/style/nsROCSSPrimitiveValue.cpp @@ -697,7 +697,7 @@ nsROCSSPrimitiveValue::Reset() case CSS_ATTR: case CSS_COUNTER: // FIXME: Counter should use an object NS_ASSERTION(mValue.mString, "Null string should never happen"); - nsMemory::Free(mValue.mString); + free(mValue.mString); mValue.mString = nullptr; break; case CSS_URI: diff --git a/layout/xul/nsMenuFrame.cpp b/layout/xul/nsMenuFrame.cpp index e7f429403ad..9b2d5a7343c 100644 --- a/layout/xul/nsMenuFrame.cpp +++ b/layout/xul/nsMenuFrame.cpp @@ -1152,7 +1152,7 @@ nsMenuFrame::BuildAcceleratorText(bool aNotify) token = nsCRT::strtok(newStr, ", \t", &newStr); } - nsMemory::Free(str); + free(str); accelText += accelString; diff --git a/media/mtransport/gonk_addrs.cpp b/media/mtransport/gonk_addrs.cpp index f3e5cc61dee..4a59f6314f2 100644 --- a/media/mtransport/gonk_addrs.cpp +++ b/media/mtransport/gonk_addrs.cpp @@ -85,7 +85,7 @@ GetInterfaces(std::vector* aInterfaces) } } - nsMemory::Free(prefixs); + free(prefixs); NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, ips); if (!isAddressGot) { diff --git a/modules/libjar/nsJAR.cpp b/modules/libjar/nsJAR.cpp index cd6fff44a55..7efde43f4a3 100644 --- a/modules/libjar/nsJAR.cpp +++ b/modules/libjar/nsJAR.cpp @@ -865,7 +865,7 @@ void nsJAR::ReportError(const nsACString &aFilename, int16_t errorCode) char* messageCstr = ToNewCString(message); if (!messageCstr) return; fprintf(stderr, "%s\n", messageCstr); - nsMemory::Free(messageCstr); + free(messageCstr); #endif } diff --git a/modules/libjar/nsJARURI.cpp b/modules/libjar/nsJARURI.cpp index ecf987d9883..22534f0d7df 100644 --- a/modules/libjar/nsJARURI.cpp +++ b/modules/libjar/nsJARURI.cpp @@ -188,7 +188,7 @@ nsJARURI::GetClassDescription(char * *aClassDescription) NS_IMETHODIMP nsJARURI::GetClassID(nsCID * *aClassID) { - *aClassID = (nsCID*) nsMemory::Alloc(sizeof(nsCID)); + *aClassID = (nsCID*) moz_xmalloc(sizeof(nsCID)); if (!*aClassID) return NS_ERROR_OUT_OF_MEMORY; return GetClassIDNoAlloc(*aClassID); diff --git a/modules/libpref/nsPrefBranch.cpp b/modules/libpref/nsPrefBranch.cpp index 3c2fd845c0c..49d77504631 100644 --- a/modules/libpref/nsPrefBranch.cpp +++ b/modules/libpref/nsPrefBranch.cpp @@ -570,7 +570,7 @@ NS_IMETHODIMP nsPrefBranch::GetChildList(const char *aStartingAt, uint32_t *aCou numPrefs = prefArray.Length(); if (numPrefs) { - outArray = (char **)nsMemory::Alloc(numPrefs * sizeof(char *)); + outArray = (char **)moz_xmalloc(numPrefs * sizeof(char *)); if (!outArray) return NS_ERROR_OUT_OF_MEMORY; diff --git a/netwerk/base/nsDirectoryIndexStream.cpp b/netwerk/base/nsDirectoryIndexStream.cpp index e4ac422c45b..715860fb0a6 100644 --- a/netwerk/base/nsDirectoryIndexStream.cpp +++ b/netwerk/base/nsDirectoryIndexStream.cpp @@ -299,7 +299,7 @@ nsDirectoryIndexStream::Read(char* aBuf, uint32_t aCount, uint32_t* aReadCount) if (escaped) { mBuf += escaped; mBuf.Append(' '); - nsMemory::Free(escaped); + free(escaped); } // The "content-length" field diff --git a/netwerk/base/nsIAuthModule.idl b/netwerk/base/nsIAuthModule.idl index e07367418ef..8a446cb219a 100644 --- a/netwerk/base/nsIAuthModule.idl +++ b/netwerk/base/nsIAuthModule.idl @@ -78,7 +78,7 @@ interface nsIAuthModule : nsISupports * If getNextToken succeeds, then aOutToken will point to a buffer * to be sent in response to the server challenge. The length of * this buffer is given by aOutTokenLength. The buffer at aOutToken - * must be recycled with a call to nsMemory::Free. + * must be recycled with a call to free. * @param aOutTokenLength * If getNextToken succeeds, then aOutTokenLength contains the * length of the buffer (number of bytes) pointed to by aOutToken. diff --git a/netwerk/base/nsProtocolProxyService.h b/netwerk/base/nsProtocolProxyService.h index 751ec160a59..706e45a49b8 100644 --- a/netwerk/base/nsProtocolProxyService.h +++ b/netwerk/base/nsProtocolProxyService.h @@ -331,7 +331,7 @@ protected: { /* other members intentionally uninitialized */ } ~HostInfo() { if (!is_ipaddr && name.host) - nsMemory::Free(name.host); + free(name.host); } }; diff --git a/netwerk/base/nsSimpleURI.cpp b/netwerk/base/nsSimpleURI.cpp index bd7e4134696..238608fb873 100644 --- a/netwerk/base/nsSimpleURI.cpp +++ b/netwerk/base/nsSimpleURI.cpp @@ -583,7 +583,7 @@ nsSimpleURI::GetClassID(nsCID * *aClassID) { // Make sure to modify any subclasses as needed if this ever // changes to not call the virtual GetClassIDNoAlloc. - *aClassID = (nsCID*) nsMemory::Alloc(sizeof(nsCID)); + *aClassID = (nsCID*) moz_xmalloc(sizeof(nsCID)); if (!*aClassID) return NS_ERROR_OUT_OF_MEMORY; return GetClassIDNoAlloc(*aClassID); diff --git a/netwerk/base/nsStandardURL.cpp b/netwerk/base/nsStandardURL.cpp index 20601608b92..c8b3e0e6948 100644 --- a/netwerk/base/nsStandardURL.cpp +++ b/netwerk/base/nsStandardURL.cpp @@ -3206,7 +3206,7 @@ nsStandardURL::GetClassDescription(char * *aClassDescription) NS_IMETHODIMP nsStandardURL::GetClassID(nsCID * *aClassID) { - *aClassID = (nsCID*) nsMemory::Alloc(sizeof(nsCID)); + *aClassID = (nsCID*) moz_xmalloc(sizeof(nsCID)); if (!*aClassID) return NS_ERROR_OUT_OF_MEMORY; return GetClassIDNoAlloc(*aClassID); diff --git a/netwerk/cache/nsCacheEntryDescriptor.cpp b/netwerk/cache/nsCacheEntryDescriptor.cpp index 806879a338f..a14f897cf51 100644 --- a/netwerk/cache/nsCacheEntryDescriptor.cpp +++ b/netwerk/cache/nsCacheEntryDescriptor.cpp @@ -923,7 +923,7 @@ nsDecompressInputStreamWrapper::Read(char * buf, // number of read requests to the input stream. uint32_t newBufLen = std::max(count, (uint32_t)kMinDecompressReadBufLen); unsigned char* newBuf; - newBuf = (unsigned char*)nsMemory::Realloc(mReadBuffer, + newBuf = (unsigned char*)moz_xrealloc(mReadBuffer, newBufLen); if (newBuf) { mReadBuffer = newBuf; @@ -986,7 +986,7 @@ nsDecompressInputStreamWrapper::Close() EndZstream(); if (mReadBuffer) { - nsMemory::Free(mReadBuffer); + free(mReadBuffer); mReadBuffer = 0; mReadBufferLen = 0; } @@ -1333,7 +1333,7 @@ nsCompressOutputStreamWrapper::Write(const char * buf, // cannot be grown. We use 2x(initial write request) to approximate // a stream buffer size proportional to request buffers. mWriteBufferLen = std::max(count*2, (uint32_t)kMinCompressWriteBufLen); - mWriteBuffer = (unsigned char*)nsMemory::Alloc(mWriteBufferLen); + mWriteBuffer = (unsigned char*)moz_xmalloc(mWriteBufferLen); if (!mWriteBuffer) { mWriteBufferLen = 0; return NS_ERROR_OUT_OF_MEMORY; @@ -1418,7 +1418,7 @@ nsCompressOutputStreamWrapper::Close() } if (mWriteBuffer) { - nsMemory::Free(mWriteBuffer); + free(mWriteBuffer); mWriteBuffer = 0; mWriteBufferLen = 0; } diff --git a/netwerk/mime/nsIMIMEHeaderParam.idl b/netwerk/mime/nsIMIMEHeaderParam.idl index fa9bd2c4fad..ffe8403d60b 100644 --- a/netwerk/mime/nsIMIMEHeaderParam.idl +++ b/netwerk/mime/nsIMIMEHeaderParam.idl @@ -59,7 +59,7 @@ interface nsIMIMEHeaderParam : nsISupports { * @param aLang If non-null, assigns it to a pointer * to a string containing the value of language * obtained from RFC 2231 parsing. Caller has to - * nsMemory::Free it. + * free it. * @return the value of aParamName in Unichar(UTF-16). */ AString getParameter(in ACString aHeaderVal, @@ -123,10 +123,10 @@ interface nsIMIMEHeaderParam : nsISupports { * the first (possibly) _unnamed_ 'parameter'. * @param aCharset If non-null, it gets assigned a new pointer * to a string containing the value of charset obtained - * from RFC 2231 parsing. Caller has to nsMemory::Free it. + * from RFC 2231 parsing. Caller has to free it. * @param aLang If non-null, it gets assigned a new pointer * to a string containing the value of language obtained - * from RFC 2231 parsing. Caller has to nsMemory::Free it. + * from RFC 2231 parsing. Caller has to free it. * @return the value of aParamName after * RFC 2231 decoding but without charset conversion. */ diff --git a/netwerk/mime/nsMIMEHeaderParamImpl.cpp b/netwerk/mime/nsMIMEHeaderParamImpl.cpp index 9e1062eafb9..2c42afa487b 100644 --- a/netwerk/mime/nsMIMEHeaderParamImpl.cpp +++ b/netwerk/mime/nsMIMEHeaderParamImpl.cpp @@ -215,7 +215,7 @@ char *combineContinuations(nsTArray& aArray) } // Allocate - char *result = (char *) nsMemory::Alloc(length + 1); + char *result = (char *) moz_xmalloc(length + 1); // Concatenate if (result) { @@ -237,7 +237,7 @@ char *combineContinuations(nsTArray& aArray) // return null if empty value if (*result == '\0') { - nsMemory::Free(result); + free(result); result = nullptr; } } else { @@ -704,9 +704,9 @@ increment_str: } // free unused stuff - nsMemory::Free(caseAResult); - nsMemory::Free(caseBResult); - nsMemory::Free(caseCDResult); + free(caseAResult); + free(caseBResult); + free(caseCDResult); // if we have a result if (*aResult) { @@ -798,7 +798,7 @@ bool IsRFC5987AttrChar(char aChar) // returns false on failure bool PercentDecode(nsACString& aValue) { - char *c = (char *) nsMemory::Alloc(aValue.Length() + 1); + char *c = (char *) moz_xmalloc(aValue.Length() + 1); if (!c) { return false; } @@ -806,7 +806,7 @@ bool PercentDecode(nsACString& aValue) strcpy(c, PromiseFlatCString(aValue).get()); nsUnescape(c); aValue.Assign(c); - nsMemory::Free(c); + free(c); return true; } diff --git a/netwerk/protocol/about/nsAboutCache.cpp b/netwerk/protocol/about/nsAboutCache.cpp index 67ce8e3f193..d918571efe3 100644 --- a/netwerk/protocol/about/nsAboutCache.cpp +++ b/netwerk/protocol/about/nsAboutCache.cpp @@ -110,7 +110,7 @@ nsAboutCache::NewChannel(nsIURI* aURI, mBuffer.AppendLiteral("Back to overview"); } @@ -195,13 +195,13 @@ nsAboutCache::FireVisitStorage() mBuffer.Append( nsPrintfCString("

Unrecognized storage name '%s' in about:cache URL

", escaped)); - nsMemory::Free(escaped); + free(escaped); } else { char* escaped = nsEscapeHTML(mContextString.get()); mBuffer.Append( nsPrintfCString("

Unrecognized context key '%s' in about:cache URL

", escaped)); - nsMemory::Free(escaped); + free(escaped); } FlushBuffer(); @@ -319,7 +319,7 @@ nsAboutCache::OnCacheStorageInfo(uint32_t aEntryCount, uint64_t aConsumption, mBuffer.AppendLiteral("&context="); char* escapedContext = nsEscapeHTML(mContextString.get()); mBuffer.Append(escapedContext); - nsMemory::Free(escapedContext); + free(escapedContext); mBuffer.AppendLiteral("\">List Cache Entries\n" " \n"); } @@ -383,12 +383,12 @@ nsAboutCache::OnCacheEntryInfo(nsIURI *aURI, const nsACString & aIdEnhance, url.AppendLiteral("&context="); char* escapedContext = nsEscapeHTML(mContextString.get()); url += escapedContext; - nsMemory::Free(escapedContext); + free(escapedContext); url.AppendLiteral("&eid="); char* escapedEID = nsEscapeHTML(aIdEnhance.BeginReading()); url += escapedEID; - nsMemory::Free(escapedEID); + free(escapedEID); nsAutoCString cacheUriSpec; aURI->GetAsciiSpec(cacheUriSpec); @@ -410,7 +410,7 @@ nsAboutCache::OnCacheEntryInfo(nsIURI *aURI, const nsACString & aIdEnhance, mBuffer.Append(escapedCacheURI); mBuffer.AppendLiteral("\n"); - nsMemory::Free(escapedCacheURI); + free(escapedCacheURI); // Content length mBuffer.AppendLiteral(" "); diff --git a/netwerk/protocol/about/nsAboutCacheEntry.cpp b/netwerk/protocol/about/nsAboutCacheEntry.cpp index 2eff941fcde..5a8c6121897 100644 --- a/netwerk/protocol/about/nsAboutCacheEntry.cpp +++ b/netwerk/protocol/about/nsAboutCacheEntry.cpp @@ -373,7 +373,7 @@ nsAboutCacheEntry::WriteCacheEntryDescription(nsICacheEntry *entry) } else { buffer.Append(escapedStr); } - nsMemory::Free(escapedStr); + free(escapedStr); buffer.AppendLiteral("\n" " \n"); @@ -506,7 +506,7 @@ nsAboutCacheEntry::OnMetaDataElement(char const * key, char const * value) " "); char* escapedValue = nsEscapeHTML(value); mBuffer->Append(escapedValue); - nsMemory::Free(escapedValue); + free(escapedValue); mBuffer->AppendLiteral("\n" " \n"); diff --git a/netwerk/protocol/device/AndroidCaptureProvider.cpp b/netwerk/protocol/device/AndroidCaptureProvider.cpp index 074c8a2f66d..dd18f6c672f 100644 --- a/netwerk/protocol/device/AndroidCaptureProvider.cpp +++ b/netwerk/protocol/device/AndroidCaptureProvider.cpp @@ -30,7 +30,7 @@ AndroidCameraInputStream::AndroidCameraInputStream() : AndroidCameraInputStream::~AndroidCameraInputStream() { // clear the frame queue while (mFrameQueue->GetSize() > 0) { - nsMemory::Free(mFrameQueue->PopFront()); + free(mFrameQueue->PopFront()); } delete mFrameQueue; } @@ -61,14 +61,14 @@ void AndroidCameraInputStream::ReceiveFrame(char* frame, uint32_t length) { { mozilla::ReentrantMonitorAutoEnter autoMonitor(mMonitor); if (mFrameQueue->GetSize() > MAX_FRAMES_QUEUED) { - nsMemory::Free(mFrameQueue->PopFront()); + free(mFrameQueue->PopFront()); mAvailable -= mFrameSize; } } mFrameSize = sizeof(RawPacketHeader) + length; - char* fullFrame = (char*)nsMemory::Alloc(mFrameSize); + char* fullFrame = (char*)moz_xmalloc(mFrameSize); if (!fullFrame) return; @@ -177,7 +177,7 @@ NS_IMETHODIMP AndroidCameraInputStream::ReadSegments(nsWriteSegmentFun aWriter, } // RawReader does a copy when calling VideoData::Create() - nsMemory::Free(frame); + free(frame); if (NS_FAILED(rv)) return NS_OK; diff --git a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp index cd1e987c9e3..5ec4cd8d20f 100644 --- a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp +++ b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp @@ -947,7 +947,7 @@ nsFtpState::R_syst() { nsXPIDLString formattedString; rv = bundle->FormatStringFromName(name.get(), formatStrings, 1, getter_Copies(formattedString)); - nsMemory::Free(ucs2Response); + free(ucs2Response); if (NS_FAILED(rv)) return FTP_ERROR; diff --git a/netwerk/protocol/ftp/nsFtpProtocolHandler.h b/netwerk/protocol/ftp/nsFtpProtocolHandler.h index 428c3106ebd..7972e1538f3 100644 --- a/netwerk/protocol/ftp/nsFtpProtocolHandler.h +++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.h @@ -52,7 +52,7 @@ private: if (timer) timer->Cancel(); if (key) - nsMemory::Free(key); + free(key); if (conn) { conn->Disconnect(NS_ERROR_ABORT); NS_RELEASE(conn); diff --git a/netwerk/protocol/http/nsHttpNTLMAuth.cpp b/netwerk/protocol/http/nsHttpNTLMAuth.cpp index 0c6d2f206cf..2e26d870f0f 100644 --- a/netwerk/protocol/http/nsHttpNTLMAuth.cpp +++ b/netwerk/protocol/http/nsHttpNTLMAuth.cpp @@ -157,7 +157,7 @@ TestPref(nsIURI *uri, const char *pref) start = end + 1; } - nsMemory::Free(hostList); + free(hostList); return false; } @@ -446,12 +446,12 @@ nsHttpNTLMAuth::GenerateCredentials(nsIHttpAuthenticableChannel *authChannel, // decode into the input secbuffer inBufLen = (len * 3)/4; // sufficient size (see plbase64.h) - inBuf = nsMemory::Alloc(inBufLen); + inBuf = moz_xmalloc(inBufLen); if (!inBuf) return NS_ERROR_OUT_OF_MEMORY; if (PL_Base64Decode(challenge, len, (char *) inBuf) == nullptr) { - nsMemory::Free(inBuf); + free(inBuf); return NS_ERROR_UNEXPECTED; // improper base64 encoding } } @@ -460,7 +460,7 @@ nsHttpNTLMAuth::GenerateCredentials(nsIHttpAuthenticableChannel *authChannel, if (NS_SUCCEEDED(rv)) { // base64 encode data in output buffer and prepend "NTLM " int credsLen = 5 + ((outBufLen + 2)/3)*4; - *creds = (char *) nsMemory::Alloc(credsLen + 1); + *creds = (char *) moz_xmalloc(credsLen + 1); if (!*creds) rv = NS_ERROR_OUT_OF_MEMORY; else { @@ -469,11 +469,11 @@ nsHttpNTLMAuth::GenerateCredentials(nsIHttpAuthenticableChannel *authChannel, (*creds)[credsLen] = '\0'; // null terminate } // OK, we are done with |outBuf| - nsMemory::Free(outBuf); + free(outBuf); } if (inBuf) - nsMemory::Free(inBuf); + free(inBuf); return rv; } diff --git a/netwerk/streamconv/converters/nsBinHexDecoder.cpp b/netwerk/streamconv/converters/nsBinHexDecoder.cpp index 372da8d3751..410b54e42ad 100644 --- a/netwerk/streamconv/converters/nsBinHexDecoder.cpp +++ b/netwerk/streamconv/converters/nsBinHexDecoder.cpp @@ -39,9 +39,9 @@ nsBinHexDecoder::nsBinHexDecoder() : nsBinHexDecoder::~nsBinHexDecoder() { if (mDataBuffer) - nsMemory::Free(mDataBuffer); + free(mDataBuffer); if (mOutgoingBuffer) - nsMemory::Free(mOutgoingBuffer); + free(mOutgoingBuffer); } NS_IMPL_ADDREF(nsBinHexDecoder) diff --git a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp index 4c43e451b8b..9c4df3b9e89 100644 --- a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp +++ b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp @@ -142,7 +142,7 @@ nsFTPDirListingConv::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, nsUnescape(unescData); printf("::OnData() sending the following %d bytes...\n\n%s\n\n", indexFormat.Length(), unescData); - nsMemory::Free(unescData); + free(unescData); #endif // DEBUG_dougt // if there's any data left over, buffer it. @@ -325,7 +325,7 @@ nsFTPDirListingConv::DigestBufferLines(char *aBuffer, nsCString &aString) { char *escapedDate = nsEscape(buffer, url_Path); aString.Append(escapedDate); - nsMemory::Free(escapedDate); + free(escapedDate); aString.Append(' '); // ENTRY TYPE diff --git a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp index d821c919e0c..a5dfadaf8f4 100644 --- a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp +++ b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp @@ -52,10 +52,10 @@ nsHTTPCompressConv::~nsHTTPCompressConv() NS_IF_RELEASE(mListener); if (mInpBuffer) - nsMemory::Free(mInpBuffer); + free(mInpBuffer); if (mOutBuffer) - nsMemory::Free(mOutBuffer); + free(mOutBuffer); // For some reason we are not getting Z_STREAM_END. But this was also seen // for mozilla bug 198133. Need to handle this case. diff --git a/netwerk/streamconv/test/TestStreamConv.cpp b/netwerk/streamconv/test/TestStreamConv.cpp index c8819499a53..48bb2c6256f 100644 --- a/netwerk/streamconv/test/TestStreamConv.cpp +++ b/netwerk/streamconv/test/TestStreamConv.cpp @@ -66,7 +66,7 @@ public: if (NS_FAILED(rv)) return rv; uint32_t len = (uint32_t)std::min(len64, (uint64_t)(UINT32_MAX - 1)); - char *buffer = (char*)nsMemory::Alloc(len + 1); + char *buffer = (char*)moz_xmalloc(len + 1); if (!buffer) return NS_ERROR_OUT_OF_MEMORY; rv = inStr->Read(buffer, len, &read); @@ -75,7 +75,7 @@ public: printf("CONTEXT %p: Received %u bytes and the following data: \n %s\n\n", static_cast(ctxt), read, buffer); } - nsMemory::Free(buffer); + free(buffer); return NS_OK; } diff --git a/netwerk/test/TestCacheBlockFiles.cpp b/netwerk/test/TestCacheBlockFiles.cpp index 4efa379d955..0a309fdf9c4 100644 --- a/netwerk/test/TestCacheBlockFiles.cpp +++ b/netwerk/test/TestCacheBlockFiles.cpp @@ -858,7 +858,7 @@ main(void) exit: if (currentDirPath) - nsMemory::Free(currentDirPath); + free(currentDirPath); } // this scopes the nsCOMPtrs // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM if (NS_FAILED(rv)) diff --git a/netwerk/test/TestMakeAbs.cpp b/netwerk/test/TestMakeAbs.cpp index 8846cf0e33f..51c21edd916 100644 --- a/netwerk/test/TestMakeAbs.cpp +++ b/netwerk/test/TestMakeAbs.cpp @@ -57,10 +57,10 @@ main(int argc, char* argv[]) while (i++ < cycles) { rv = ServiceMakeAbsolute(uri, rel, &absURLString); if (NS_FAILED(rv)) return rv; - nsMemory::Free(absURLString); + free(absURLString); rv = URLMakeAbsolute(uri, rel, &absURLString); - nsMemory::Free(absURLString); + free(absURLString); } } // this scopes the nsCOMPtrs // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp index 3e34aa3636d..37f872df149 100644 --- a/parser/html/nsHtml5TreeOperation.cpp +++ b/parser/html/nsHtml5TreeOperation.cpp @@ -108,7 +108,7 @@ nsHtml5TreeOperation::~nsHtml5TreeOperation() delete[] mOne.charPtr; break; case eTreeOpProcessOfflineManifest: - nsMemory::Free(mOne.unicharPtr); + free(mOne.unicharPtr); break; default: // keep the compiler happy break; diff --git a/security/manager/pki/src/nsNSSDialogs.cpp b/security/manager/pki/src/nsNSSDialogs.cpp index ffab9290f9f..2e3c615a094 100644 --- a/security/manager/pki/src/nsNSSDialogs.cpp +++ b/security/manager/pki/src/nsNSSDialogs.cpp @@ -333,7 +333,7 @@ nsNSSDialogs::SetPKCS12FilePassword(nsIInterfaceRequestor *ctx, rv = block->GetString(2, &pw); if (NS_SUCCEEDED(rv)) { _password = pw; - nsMemory::Free(pw); + free(pw); } } return rv; @@ -371,7 +371,7 @@ nsNSSDialogs::GetPKCS12FilePassword(nsIInterfaceRequestor* ctx, if (*_retval) { _password.Assign(pwTemp); - nsMemory::Free(pwTemp); + free(pwTemp); } return NS_OK; diff --git a/security/manager/ssl/src/PSMContentListener.cpp b/security/manager/ssl/src/PSMContentListener.cpp index 0526df88563..789aac0fa66 100644 --- a/security/manager/ssl/src/PSMContentListener.cpp +++ b/security/manager/ssl/src/PSMContentListener.cpp @@ -63,7 +63,7 @@ PSMContentDownloader::PSMContentDownloader(uint32_t type) PSMContentDownloader::~PSMContentDownloader() { if (mByteData) - nsMemory::Free(mByteData); + free(mByteData); } NS_IMPL_ISUPPORTS(PSMContentDownloader, nsIStreamListener, nsIRequestObserver) @@ -90,7 +90,7 @@ PSMContentDownloader::OnStartRequest(nsIRequest* request, nsISupports* context) mBufferOffset = 0; mBufferSize = 0; - mByteData = (char*)nsMemory::Alloc(AssertedCast(contentLength)); + mByteData = (char*)moz_xmalloc(AssertedCast(contentLength)); if (!mByteData) return NS_ERROR_OUT_OF_MEMORY; @@ -114,7 +114,7 @@ PSMContentDownloader::OnDataAvailable(nsIRequest* request, if ((mBufferOffset + (int32_t)aLength) > mBufferSize) { size_t newSize = (mBufferOffset + aLength) *2; // grow some more than needed char *newBuffer; - newBuffer = (char*)nsMemory::Realloc(mByteData, newSize); + newBuffer = (char*)moz_xrealloc(mByteData, newSize); if (!newBuffer) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/security/manager/ssl/src/TransportSecurityInfo.cpp b/security/manager/ssl/src/TransportSecurityInfo.cpp index d3d8e11dac9..e9eb55108ee 100644 --- a/security/manager/ssl/src/TransportSecurityInfo.cpp +++ b/security/manager/ssl/src/TransportSecurityInfo.cpp @@ -469,7 +469,7 @@ TransportSecurityInfo::GetClassDescription(char * *aClassDescription) NS_IMETHODIMP TransportSecurityInfo::GetClassID(nsCID * *aClassID) { - *aClassID = (nsCID*) nsMemory::Alloc(sizeof(nsCID)); + *aClassID = (nsCID*) moz_xmalloc(sizeof(nsCID)); if (!*aClassID) return NS_ERROR_OUT_OF_MEMORY; return GetClassIDNoAlloc(*aClassID); diff --git a/security/manager/ssl/src/nsCertPicker.cpp b/security/manager/ssl/src/nsCertPicker.cpp index bce9601e7d4..ad6d9f28f9a 100644 --- a/security/manager/ssl/src/nsCertPicker.cpp +++ b/security/manager/ssl/src/nsCertPicker.cpp @@ -71,12 +71,12 @@ NS_IMETHODIMP nsCertPicker::PickByUsage(nsIInterfaceRequestor *ctx, return NS_ERROR_NOT_AVAILABLE; } - certNicknameList = (char16_t **)nsMemory::Alloc(sizeof(char16_t *) * nicknames->numnicknames); - certDetailsList = (char16_t **)nsMemory::Alloc(sizeof(char16_t *) * nicknames->numnicknames); + certNicknameList = (char16_t **)moz_xmalloc(sizeof(char16_t *) * nicknames->numnicknames); + certDetailsList = (char16_t **)moz_xmalloc(sizeof(char16_t *) * nicknames->numnicknames); if (!certNicknameList || !certDetailsList) { - nsMemory::Free(certNicknameList); - nsMemory::Free(certDetailsList); + free(certNicknameList); + free(certDetailsList); return NS_ERROR_OUT_OF_MEMORY; } @@ -147,11 +147,11 @@ NS_IMETHODIMP nsCertPicker::PickByUsage(nsIInterfaceRequestor *ctx, int32_t i; for (i = 0; i < CertsToUse; ++i) { - nsMemory::Free(certNicknameList[i]); - nsMemory::Free(certDetailsList[i]); + free(certNicknameList[i]); + free(certDetailsList[i]); } - nsMemory::Free(certNicknameList); - nsMemory::Free(certDetailsList); + free(certNicknameList); + free(certDetailsList); if (!CertsToUse) { return NS_ERROR_NOT_AVAILABLE; diff --git a/security/manager/ssl/src/nsKeygenHandler.cpp b/security/manager/ssl/src/nsKeygenHandler.cpp index 68cfbc5125f..ad0279b45c9 100644 --- a/security/manager/ssl/src/nsKeygenHandler.cpp +++ b/security/manager/ssl/src/nsKeygenHandler.cpp @@ -389,7 +389,7 @@ GetSlotWithMechanism(uint32_t aMechanism, } // Allocate the slot name buffer // - tokenNameList = static_cast(nsMemory::Alloc(sizeof(char16_t *) * numSlots)); + tokenNameList = static_cast(moz_xmalloc(sizeof(char16_t *) * numSlots)); if (!tokenNameList) { rv = NS_ERROR_OUT_OF_MEMORY; goto loser; @@ -761,10 +761,10 @@ loser: NS_RELEASE(KeygenRunnable); } if (keyparamsString) { - nsMemory::Free(keyparamsString); + free(keyparamsString); } if (pkac.challenge.data) { - nsMemory::Free(pkac.challenge.data); + free(pkac.challenge.data); } return rv; } diff --git a/security/manager/ssl/src/nsNSSASN1Object.cpp b/security/manager/ssl/src/nsNSSASN1Object.cpp index d31ca450982..7f74150fb72 100644 --- a/security/manager/ssl/src/nsNSSASN1Object.cpp +++ b/security/manager/ssl/src/nsNSSASN1Object.cpp @@ -336,7 +336,7 @@ nsNSSASN1PrintableItem::~nsNSSASN1PrintableItem() { /* destructor code */ if (mData) - nsMemory::Free(mData); + free(mData); } /* readonly attribute wstring value; */ @@ -387,7 +387,7 @@ nsNSSASN1PrintableItem::SetData(char *data, uint32_t len) { if (len > 0) { if (mLen < len) { - unsigned char* newData = (unsigned char*)nsMemory::Realloc(mData, len); + unsigned char* newData = (unsigned char*)moz_xrealloc(mData, len); if (!newData) return NS_ERROR_OUT_OF_MEMORY; @@ -397,7 +397,7 @@ nsNSSASN1PrintableItem::SetData(char *data, uint32_t len) memcpy(mData, data, len); } else if (len == 0) { if (mData) { - nsMemory::Free(mData); + free(mData); mData = nullptr; } } diff --git a/security/manager/ssl/src/nsNSSCallbacks.cpp b/security/manager/ssl/src/nsNSSCallbacks.cpp index b288cbf0079..f97cdeb6592 100644 --- a/security/manager/ssl/src/nsNSSCallbacks.cpp +++ b/security/manager/ssl/src/nsNSSCallbacks.cpp @@ -835,7 +835,7 @@ void PK11PasswordPromptRunnable::RunOnTargetThread() rv = nssComponent->PIPBundleFormatStringFromName("CertPassPrompt", formatStrings, 1, promptString); - nsMemory::Free(const_cast(formatStrings[0])); + free(const_cast(formatStrings[0])); if (NS_FAILED(rv)) return; diff --git a/security/manager/ssl/src/nsNSSCertHelper.cpp b/security/manager/ssl/src/nsNSSCertHelper.cpp index 76ab9d1a342..fe15c9e0f71 100644 --- a/security/manager/ssl/src/nsNSSCertHelper.cpp +++ b/security/manager/ssl/src/nsNSSCertHelper.cpp @@ -670,7 +670,7 @@ ProcessKeyUsageExtension(SECItem *extData, nsAString &text, if (decoded.len) { keyUsage = decoded.data[0]; } - nsMemory::Free(decoded.data); + free(decoded.data); if (keyUsage & KU_DIGITAL_SIGNATURE) { nssComponent->GetPIPNSSBundleString("CertDumpKUSign", local); text.Append(local.get()); @@ -901,7 +901,7 @@ ProcessIA5String(SECItem *extData, extData)) return NS_ERROR_FAILURE; local.AssignASCII((char*)item.data, item.len); - nsMemory::Free(item.data); + free(item.data); text.Append(local); return NS_OK; } @@ -1516,7 +1516,7 @@ ProcessMSCAVersion(SECItem *extData, return ProcessRawBytes(nssComponent, extData, text); rv = GetIntValue(&decoded, &version); - nsMemory::Free(decoded.data); + free(decoded.data); if (NS_FAILED(rv)) /* Value out of range, display raw bytes */ return ProcessRawBytes(nssComponent, extData, text); diff --git a/security/manager/ssl/src/nsNSSCertificate.cpp b/security/manager/ssl/src/nsNSSCertificate.cpp index 1fc86818dad..98126653254 100644 --- a/security/manager/ssl/src/nsNSSCertificate.cpp +++ b/security/manager/ssl/src/nsNSSCertificate.cpp @@ -502,7 +502,7 @@ nsNSSCertificate::GetDbKey(char** aDbKey) NS_ENSURE_ARG(aDbKey); *aDbKey = nullptr; key.len = NS_NSS_LONG*4+mCert->serialNumber.len+mCert->derIssuer.len; - key.data = (unsigned char*) nsMemory::Alloc(key.len); + key.data = (unsigned char*) moz_xmalloc(key.len); if (!key.data) return NS_ERROR_OUT_OF_MEMORY; NS_NSS_PUT_LONG(0,key.data); // later put moduleID @@ -515,7 +515,7 @@ nsNSSCertificate::GetDbKey(char** aDbKey) mCert->derIssuer.data, mCert->derIssuer.len); *aDbKey = NSSBase64_EncodeItem(nullptr, nullptr, 0, &key); - nsMemory::Free(key.data); // SECItem is a 'c' type without a destrutor + free(key.data); // SECItem is a 'c' type without a destructor return (*aDbKey) ? NS_OK : NS_ERROR_FAILURE; } @@ -622,7 +622,7 @@ nsNSSCertificate::GetEmailAddresses(uint32_t* aLength, char16_t*** aAddresses) ++(*aLength); } - *aAddresses = (char16_t**) nsMemory::Alloc(sizeof(char16_t*) * (*aLength)); + *aAddresses = (char16_t**) moz_xmalloc(sizeof(char16_t*) * (*aLength)); if (!*aAddresses) return NS_ERROR_OUT_OF_MEMORY; @@ -939,7 +939,7 @@ nsNSSCertificate::GetAllTokenNames(uint32_t* aLength, char16_t*** aTokenNames) ++(*aLength); } - *aTokenNames = (char16_t**) nsMemory::Alloc(sizeof(char16_t*) * (*aLength)); + *aTokenNames = (char16_t**) moz_xmalloc(sizeof(char16_t*) * (*aLength)); if (!*aTokenNames) { *aLength = 0; return NS_ERROR_OUT_OF_MEMORY; @@ -1114,7 +1114,7 @@ nsNSSCertificate::GetRawDER(uint32_t* aLength, uint8_t** aArray) return NS_ERROR_NOT_AVAILABLE; if (mCert) { - *aArray = (uint8_t*)nsMemory::Alloc(mCert->derCert.len); + *aArray = (uint8_t*)moz_xmalloc(mCert->derCert.len); if (*aArray) { memcpy(*aArray, mCert->derCert.data, mCert->derCert.len); *aLength = mCert->derCert.len; @@ -1240,7 +1240,7 @@ nsNSSCertificate::ExportAsCMS(uint32_t chainMode, return NS_ERROR_FAILURE; } - *aArray = (uint8_t*)nsMemory::Alloc(certP7.len); + *aArray = (uint8_t*)moz_xmalloc(certP7.len); if (!*aArray) return NS_ERROR_OUT_OF_MEMORY; @@ -1294,7 +1294,7 @@ nsNSSCertificate::GetUsagesArray(bool localOnly, tmpUsages); NS_ENSURE_SUCCESS(rv,rv); if (tmpCount > 0) { - *_usages = (char16_t**) nsMemory::Alloc(sizeof(char16_t*) * tmpCount); + *_usages = (char16_t**) moz_xmalloc(sizeof(char16_t*) * tmpCount); if (!*_usages) return NS_ERROR_OUT_OF_MEMORY; for (uint32_t i=0; i0) _usages.Append(','); _usages.Append(tmpUsages[i]); - nsMemory::Free(tmpUsages[i]); + free(tmpUsages[i]); } return NS_OK; } @@ -1943,7 +1943,7 @@ nsNSSCertificate::GetClassDescription(char** aClassDescription) NS_IMETHODIMP nsNSSCertificate::GetClassID(nsCID** aClassID) { - *aClassID = (nsCID*) nsMemory::Alloc(sizeof(nsCID)); + *aClassID = (nsCID*) moz_xmalloc(sizeof(nsCID)); if (!*aClassID) return NS_ERROR_OUT_OF_MEMORY; return GetClassIDNoAlloc(*aClassID); diff --git a/security/manager/ssl/src/nsNSSCertificateDB.cpp b/security/manager/ssl/src/nsNSSCertificateDB.cpp index 830043849c7..11e64bfaacd 100644 --- a/security/manager/ssl/src/nsNSSCertificateDB.cpp +++ b/security/manager/ssl/src/nsNSSCertificateDB.cpp @@ -355,7 +355,7 @@ nsNSSCertificateDB::handleCACertDownload(nsIArray *x509Certs, tmpCert = CERT_NewTempCertificate(certdb, &der, nullptr, false, true); } - nsMemory::Free(der.data); + free(der.data); der.data = nullptr; der.len = 0; @@ -424,7 +424,7 @@ nsNSSCertificateDB::handleCACertDownload(nsIArray *x509Certs, CERTCertificate *tmpCert2 = CERT_NewTempCertificate(certdb, &der, nullptr, false, true); - nsMemory::Free(der.data); + free(der.data); der.data = nullptr; der.len = 0; @@ -1233,7 +1233,7 @@ nsNSSCertificateDB::getCertNames(CERTCertList *certList, } PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("num certs: %d\n", numcerts)); int nc = (numcerts == 0) ? 1 : numcerts; - tmpArray = (char16_t **)nsMemory::Alloc(sizeof(char16_t *) * nc); + tmpArray = (char16_t **)moz_xmalloc(sizeof(char16_t *) * nc); if (numcerts == 0) goto finish; for (node = CERT_LIST_HEAD(certList); !CERT_LIST_END(node, certList); @@ -1620,7 +1620,7 @@ NS_IMETHODIMP nsNSSCertificateDB::AddCertFromBase64(const char* aBase64, if (!tmpCert) tmpCert = CERT_NewTempCertificate(certdb, &der, nullptr, false, true); - nsMemory::Free(der.data); + free(der.data); der.data = nullptr; der.len = 0; diff --git a/security/manager/ssl/src/nsNSSCertificateFakeTransport.cpp b/security/manager/ssl/src/nsNSSCertificateFakeTransport.cpp index 15b24a766b5..3b058202dcd 100644 --- a/security/manager/ssl/src/nsNSSCertificateFakeTransport.cpp +++ b/security/manager/ssl/src/nsNSSCertificateFakeTransport.cpp @@ -312,7 +312,7 @@ nsNSSCertificateFakeTransport::GetClassDescription(char** aClassDescription) NS_IMETHODIMP nsNSSCertificateFakeTransport::GetClassID(nsCID** aClassID) { - *aClassID = (nsCID*) nsMemory::Alloc(sizeof(nsCID)); + *aClassID = (nsCID*) moz_xmalloc(sizeof(nsCID)); if (!*aClassID) return NS_ERROR_OUT_OF_MEMORY; return GetClassIDNoAlloc(*aClassID); diff --git a/security/manager/ssl/src/nsNSSIOLayer.cpp b/security/manager/ssl/src/nsNSSIOLayer.cpp index b150d8bf83e..13c0cdd8e23 100644 --- a/security/manager/ssl/src/nsNSSIOLayer.cpp +++ b/security/manager/ssl/src/nsNSSIOLayer.cpp @@ -1971,7 +1971,7 @@ nsGetUserCertChoice(SSM_UserCertChoice* certChoice) loser: if (mode) { - nsMemory::Free(mode); + free(mode); } return ret; } @@ -2342,13 +2342,13 @@ ClientAuthDataRunnable::RunOnTargetThread() if (cissuer) PORT_Free(cissuer); certNicknameList = - (char16_t**)nsMemory::Alloc(sizeof(char16_t*)* nicknames->numnicknames); + (char16_t**)moz_xmalloc(sizeof(char16_t*)* nicknames->numnicknames); if (!certNicknameList) goto loser; certDetailsList = - (char16_t**)nsMemory::Alloc(sizeof(char16_t*)* nicknames->numnicknames); + (char16_t**)moz_xmalloc(sizeof(char16_t*)* nicknames->numnicknames); if (!certDetailsList) { - nsMemory::Free(certNicknameList); + free(certNicknameList); goto loser; } @@ -2373,7 +2373,7 @@ ClientAuthDataRunnable::RunOnTargetThread() continue; certDetailsList[CertsToUse] = ToNewUnicode(details); if (!certDetailsList[CertsToUse]) { - nsMemory::Free(certNicknameList[CertsToUse]); + free(certNicknameList[CertsToUse]); continue; } diff --git a/security/manager/ssl/src/nsNTLMAuthModule.cpp b/security/manager/ssl/src/nsNTLMAuthModule.cpp index ced249e3ed4..80bc6bfff48 100644 --- a/security/manager/ssl/src/nsNTLMAuthModule.cpp +++ b/security/manager/ssl/src/nsNTLMAuthModule.cpp @@ -409,7 +409,7 @@ GenerateType1Msg(void **outBuf, uint32_t *outLen) // verify that bufLen is sufficient // *outLen = NTLM_TYPE1_HEADER_LEN; - *outBuf = nsMemory::Alloc(*outLen); + *outBuf = moz_xmalloc(*outLen); if (!*outBuf) return NS_ERROR_OUT_OF_MEMORY; @@ -877,7 +877,7 @@ GenerateType3Msg(const nsString &domain, NS_ERROR("failed preparing to allocate NTLM response: integer overflow?!?"); return NS_ERROR_FAILURE; } - *outBuf = nsMemory::Alloc(totalLen.value()); + *outBuf = moz_xmalloc(totalLen.value()); *outLen = totalLen.value(); if (!*outBuf) { return NS_ERROR_OUT_OF_MEMORY; diff --git a/security/manager/ssl/src/nsPKCS11Slot.cpp b/security/manager/ssl/src/nsPKCS11Slot.cpp index 94f753ae062..baf1dd47ef8 100644 --- a/security/manager/ssl/src/nsPKCS11Slot.cpp +++ b/security/manager/ssl/src/nsPKCS11Slot.cpp @@ -320,11 +320,11 @@ nsPKCS11Module::FindSlotByName(const char16_t *aName, slotinfo = PK11_ReferenceSlot(mModule->slots[0]); } else { // give up - nsMemory::Free(asciiname); + free(asciiname); return NS_ERROR_FAILURE; } } - nsMemory::Free(asciiname); + free(asciiname); nsCOMPtr slot = new nsPKCS11Slot(slotinfo); PK11_FreeSlot(slotinfo); *_retval = slot; diff --git a/security/manager/ssl/src/nsSDR.cpp b/security/manager/ssl/src/nsSDR.cpp index 767cbdd4c14..f00da3fcc3c 100644 --- a/security/manager/ssl/src/nsSDR.cpp +++ b/security/manager/ssl/src/nsSDR.cpp @@ -178,7 +178,7 @@ DecryptString(const char *crypt, char **_retval) if (rv != NS_OK) goto loser; // Convert to NUL-terminated string - r = (char *)nsMemory::Alloc(decryptedLen+1); + r = (char *)moz_xmalloc(decryptedLen+1); if (!r) { rv = NS_ERROR_OUT_OF_MEMORY; goto loser; } memcpy(r, decrypted, decryptedLen); diff --git a/security/manager/ssl/src/nsSSLStatus.cpp b/security/manager/ssl/src/nsSSLStatus.cpp index 369413385b2..2b73536ca3d 100644 --- a/security/manager/ssl/src/nsSSLStatus.cpp +++ b/security/manager/ssl/src/nsSSLStatus.cpp @@ -236,7 +236,7 @@ nsSSLStatus::GetClassDescription(char** aClassDescription) NS_IMETHODIMP nsSSLStatus::GetClassID(nsCID** aClassID) { - *aClassID = (nsCID*) nsMemory::Alloc(sizeof(nsCID)); + *aClassID = (nsCID*) moz_xmalloc(sizeof(nsCID)); if (!*aClassID) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/toolkit/components/downloads/ApplicationReputation.cpp b/toolkit/components/downloads/ApplicationReputation.cpp index 8ae98772281..e984e34eae7 100644 --- a/toolkit/components/downloads/ApplicationReputation.cpp +++ b/toolkit/components/downloads/ApplicationReputation.cpp @@ -779,7 +779,7 @@ PendingLookup::ParseCertificates(nsIArray* aSigArray) // Add this certificate to the protobuf to send remotely. certChain->add_element()->set_certificate(data, len); - nsMemory::Free(data); + free(data); rv = chainElt->HasMoreElements(&hasMoreCerts); NS_ENSURE_SUCCESS(rv, rv); diff --git a/toolkit/components/places/nsAnnotationService.cpp b/toolkit/components/places/nsAnnotationService.cpp index 23a6ebb5163..f4b4a57f519 100644 --- a/toolkit/components/places/nsAnnotationService.cpp +++ b/toolkit/components/places/nsAnnotationService.cpp @@ -972,7 +972,7 @@ nsAnnotationService::GetPagesWithAnnotation(const nsACString& aName, return NS_OK; *_results = static_cast - (nsMemory::Alloc(results.Count() * sizeof(nsIURI*))); + (moz_xmalloc(results.Count() * sizeof(nsIURI*))); NS_ENSURE_TRUE(*_results, NS_ERROR_OUT_OF_MEMORY); *_resultCount = results.Count(); @@ -1045,7 +1045,7 @@ nsAnnotationService::GetItemsWithAnnotation(const nsACString& aName, return NS_OK; *_results = static_cast - (nsMemory::Alloc(results.Length() * sizeof(int64_t))); + (moz_xmalloc(results.Length() * sizeof(int64_t))); NS_ENSURE_TRUE(*_results, NS_ERROR_OUT_OF_MEMORY); *_resultCount = results.Length(); @@ -1150,7 +1150,7 @@ nsAnnotationService::GetAnnotationsWithName(const nsACString& aName, return NS_OK; *_annotations = static_cast - (nsMemory::Alloc(annotations.Count() * sizeof(mozIAnnotatedResult*))); + (moz_xmalloc(annotations.Count() * sizeof(mozIAnnotatedResult*))); NS_ENSURE_TRUE(*_annotations, NS_ERROR_OUT_OF_MEMORY); *_count = annotations.Count(); @@ -1209,7 +1209,7 @@ nsAnnotationService::GetPageAnnotationNames(nsIURI* aURI, return NS_OK; *_result = static_cast - (nsMemory::Alloc(sizeof(nsIVariant*) * names.Length())); + (moz_xmalloc(sizeof(nsIVariant*) * names.Length())); NS_ENSURE_TRUE(*_result, NS_ERROR_OUT_OF_MEMORY); for (uint32_t i = 0; i < names.Length(); i ++) { @@ -1218,7 +1218,7 @@ nsAnnotationService::GetPageAnnotationNames(nsIURI* aURI, // need to release all the variants we've already created for (uint32_t j = 0; j < i; j ++) NS_RELEASE((*_result)[j]); - nsMemory::Free(*_result); + free(*_result); *_result = nullptr; return NS_ERROR_OUT_OF_MEMORY; } @@ -1301,7 +1301,7 @@ nsAnnotationService::GetItemAnnotationNames(int64_t aItemId, return NS_OK; *_result = static_cast - (nsMemory::Alloc(sizeof(nsIVariant*) * names.Length())); + (moz_xmalloc(sizeof(nsIVariant*) * names.Length())); NS_ENSURE_TRUE(*_result, NS_ERROR_OUT_OF_MEMORY); for (uint32_t i = 0; i < names.Length(); i ++) { @@ -1310,7 +1310,7 @@ nsAnnotationService::GetItemAnnotationNames(int64_t aItemId, // need to release all the variants we've already created for (uint32_t j = 0; j < i; j ++) NS_RELEASE((*_result)[j]); - nsMemory::Free(*_result); + free(*_result); *_result = nullptr; return NS_ERROR_OUT_OF_MEMORY; } diff --git a/toolkit/components/places/nsFaviconService.cpp b/toolkit/components/places/nsFaviconService.cpp index b46f1b1d0ef..909a018eb2a 100644 --- a/toolkit/components/places/nsFaviconService.cpp +++ b/toolkit/components/places/nsFaviconService.cpp @@ -356,26 +356,26 @@ nsFaviconService::ReplaceFaviconDataFromDataURL(nsIURI* aFaviconURI, // Read all the decoded data. uint8_t* buffer = static_cast - (nsMemory::Alloc(sizeof(uint8_t) * available)); + (moz_xmalloc(sizeof(uint8_t) * available)); if (!buffer) return NS_ERROR_OUT_OF_MEMORY; uint32_t numRead; rv = stream->Read(TO_CHARBUFFER(buffer), available, &numRead); if (NS_FAILED(rv) || numRead != available) { - nsMemory::Free(buffer); + free(buffer); return rv; } nsAutoCString mimeType; rv = channel->GetContentType(mimeType); if (NS_FAILED(rv)) { - nsMemory::Free(buffer); + free(buffer); return rv; } // ReplaceFaviconData can now do the dirty work. rv = ReplaceFaviconData(aFaviconURI, buffer, available, mimeType, aExpiration); - nsMemory::Free(buffer); + free(buffer); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; diff --git a/toolkit/components/places/nsNavBookmarks.cpp b/toolkit/components/places/nsNavBookmarks.cpp index c66116dd00a..452fa27b994 100644 --- a/toolkit/components/places/nsNavBookmarks.cpp +++ b/toolkit/components/places/nsNavBookmarks.cpp @@ -2148,7 +2148,7 @@ nsNavBookmarks::GetBookmarkIdsForURI(nsIURI* aURI, uint32_t* aCount, // Copy the results into a new array for output if (bookmarks.Length()) { *aBookmarks = - static_cast(nsMemory::Alloc(sizeof(int64_t) * bookmarks.Length())); + static_cast(moz_xmalloc(sizeof(int64_t) * bookmarks.Length())); if (!*aBookmarks) return NS_ERROR_OUT_OF_MEMORY; for (uint32_t i = 0; i < bookmarks.Length(); i ++) @@ -2543,7 +2543,7 @@ nsNavBookmarks::GetObservers(uint32_t* _count, return NS_OK; *_observers = static_cast - (nsMemory::Alloc(observers.Count() * sizeof(nsINavBookmarkObserver*))); + (moz_xmalloc(observers.Count() * sizeof(nsINavBookmarkObserver*))); NS_ENSURE_TRUE(*_observers, NS_ERROR_OUT_OF_MEMORY); *_count = observers.Count(); diff --git a/toolkit/components/places/nsNavHistory.cpp b/toolkit/components/places/nsNavHistory.cpp index 25f48a2a151..dbe6bd77f5c 100644 --- a/toolkit/components/places/nsNavHistory.cpp +++ b/toolkit/components/places/nsNavHistory.cpp @@ -2290,7 +2290,7 @@ nsNavHistory::GetObservers(uint32_t* _count, return NS_OK; *_observers = static_cast - (nsMemory::Alloc(observers.Count() * sizeof(nsINavHistoryObserver*))); + (moz_xmalloc(observers.Count() * sizeof(nsINavHistoryObserver*))); NS_ENSURE_TRUE(*_observers, NS_ERROR_OUT_OF_MEMORY); *_count = observers.Count(); diff --git a/toolkit/components/places/nsNavHistoryQuery.cpp b/toolkit/components/places/nsNavHistoryQuery.cpp index ff0639812ed..fa82c5dd7b8 100644 --- a/toolkit/components/places/nsNavHistoryQuery.cpp +++ b/toolkit/components/places/nsNavHistoryQuery.cpp @@ -275,7 +275,7 @@ nsNavHistory::QueryStringToQueries(const nsACString& aQueryString, if (queries.Count() > 0) { // convert COM array to raw *aQueries = static_cast - (nsMemory::Alloc(sizeof(nsINavHistoryQuery*) * queries.Count())); + (moz_xmalloc(sizeof(nsINavHistoryQuery*) * queries.Count())); NS_ENSURE_TRUE(*aQueries, NS_ERROR_OUT_OF_MEMORY); for (int32_t i = 0; i < queries.Count(); i ++) { (*aQueries)[i] = queries[i]; @@ -471,7 +471,7 @@ nsNavHistory::QueriesToQueryString(nsINavHistoryQuery **aQueries, nsresult rv = PlacesFolderConversion::AppendFolder(queryString, folders[i]); NS_ENSURE_SUCCESS(rv, rv); } - nsMemory::Free(folders); + free(folders); // tags const nsTArray &tags = query->Tags(); @@ -1274,7 +1274,7 @@ NS_IMETHODIMP nsNavHistoryQuery::GetFolders(uint32_t *aCount, int64_t *folders = nullptr; if (count > 0) { folders = static_cast - (nsMemory::Alloc(count * sizeof(int64_t))); + (moz_xmalloc(count * sizeof(int64_t))); NS_ENSURE_TRUE(folders, NS_ERROR_OUT_OF_MEMORY); for (uint32_t i = 0; i < count; ++i) { diff --git a/toolkit/components/places/nsNavHistoryResult.cpp b/toolkit/components/places/nsNavHistoryResult.cpp index 356625baa42..28ebcc5b250 100644 --- a/toolkit/components/places/nsNavHistoryResult.cpp +++ b/toolkit/components/places/nsNavHistoryResult.cpp @@ -2013,7 +2013,7 @@ nsNavHistoryQueryResultNode::GetQueries(uint32_t* queryCount, NS_ASSERTION(mQueries.Count() > 0, "Must have >= 1 query"); *queries = static_cast - (nsMemory::Alloc(mQueries.Count() * sizeof(nsINavHistoryQuery*))); + (moz_xmalloc(mQueries.Count() * sizeof(nsINavHistoryQuery*))); NS_ENSURE_TRUE(*queries, NS_ERROR_OUT_OF_MEMORY); for (int32_t i = 0; i < mQueries.Count(); ++i) @@ -3108,7 +3108,7 @@ nsNavHistoryFolderResultNode::GetUri(nsACString& aURI) for (uint32_t queryIndex = 0; queryIndex < queryCount; ++queryIndex) { NS_RELEASE(queries[queryIndex]); } - nsMemory::Free(queries); + free(queries); return rv; } @@ -3133,7 +3133,7 @@ nsNavHistoryFolderResultNode::GetQueries(uint32_t* queryCount, // make array of our 1 query *queries = static_cast - (nsMemory::Alloc(sizeof(nsINavHistoryQuery*))); + (moz_xmalloc(sizeof(nsINavHistoryQuery*))); if (!*queries) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF((*queries)[0] = query); diff --git a/toolkit/components/telemetry/Telemetry.cpp b/toolkit/components/telemetry/Telemetry.cpp index 58702c62b9e..e53ec562f87 100644 --- a/toolkit/components/telemetry/Telemetry.cpp +++ b/toolkit/components/telemetry/Telemetry.cpp @@ -3076,7 +3076,7 @@ GetRegisteredHistogramIds(bool keyed, uint32_t dataset, uint32_t *aCount, } const size_t bytes = collection.Length() * sizeof(char*); - char** histograms = static_cast(nsMemory::Alloc(bytes)); + char** histograms = static_cast(moz_xmalloc(bytes)); memcpy(histograms, collection.Elements(), bytes); *aHistograms = histograms; *aCount = collection.Length(); diff --git a/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp b/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp index 9604fec4dd5..6dce42b4385 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp @@ -177,7 +177,7 @@ nsUrlClassifierPrefixSet::GetPrefixes(uint32_t* aCount, } uint64_t itemCount = prefixes.Length(); - uint32_t* prefixArray = static_cast(nsMemory::Alloc(itemCount * sizeof(uint32_t))); + uint32_t* prefixArray = static_cast(moz_xmalloc(itemCount * sizeof(uint32_t))); NS_ENSURE_TRUE(prefixArray, NS_ERROR_OUT_OF_MEMORY); memcpy(prefixArray, prefixes.Elements(), sizeof(uint32_t) * itemCount); diff --git a/toolkit/xre/nsAndroidStartup.cpp b/toolkit/xre/nsAndroidStartup.cpp index efbb8f5b56c..bf40f7fb5a7 100644 --- a/toolkit/xre/nsAndroidStartup.cpp +++ b/toolkit/xre/nsAndroidStartup.cpp @@ -78,6 +78,6 @@ GeckoStart(void *data, const nsXREAppData *appData) mozilla::widget::GeckoAppShell::NotifyXreExit(); free(targs[0]); - nsMemory::Free(data); + free(data); return; } diff --git a/tools/profiler/nsProfiler.cpp b/tools/profiler/nsProfiler.cpp index 694d3f0e395..b9ed68c3d07 100644 --- a/tools/profiler/nsProfiler.cpp +++ b/tools/profiler/nsProfiler.cpp @@ -236,7 +236,7 @@ nsProfiler::GetFeatures(uint32_t *aCount, char ***aFeatures) } char **featureList = static_cast - (nsMemory::Alloc(len * sizeof(char*))); + (moz_xmalloc(len * sizeof(char*))); for (size_t i = 0; i < len; i++) { size_t strLen = strlen(features[i]); diff --git a/widget/GfxInfoBase.cpp b/widget/GfxInfoBase.cpp index 154c7f032ec..e1bff0c593b 100644 --- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -919,7 +919,7 @@ GfxInfoBase::LogFailure(const nsACString &failure) } /* void getFailures (out unsigned long failureCount, [optional, array, size_is (failureCount)] out long indices, [array, size_is (failureCount), retval] out string failures); */ -/* XPConnect method of returning arrays is very ugly. Would not recommend. Fallable nsMemory::Alloc makes things worse */ +/* XPConnect method of returning arrays is very ugly. Would not recommend. */ NS_IMETHODIMP GfxInfoBase::GetFailures(uint32_t* failureCount, int32_t** indices, char ***failures) @@ -950,14 +950,14 @@ NS_IMETHODIMP GfxInfoBase::GetFailures(uint32_t* failureCount, *failureCount = loggedStrings.size(); if (*failureCount != 0) { - *failures = (char**)nsMemory::Alloc(*failureCount * sizeof(char*)); + *failures = (char**)moz_xmalloc(*failureCount * sizeof(char*)); if (!(*failures)) { return NS_ERROR_OUT_OF_MEMORY; } if (indices) { - *indices = (int32_t*)nsMemory::Alloc(*failureCount * sizeof(int32_t)); + *indices = (int32_t*)moz_xmalloc(*failureCount * sizeof(int32_t)); if (!(*indices)) { - nsMemory::Free(*failures); + free(*failures); *failures = nullptr; return NS_ERROR_OUT_OF_MEMORY; } diff --git a/widget/android/nsAppShell.cpp b/widget/android/nsAppShell.cpp index e17c266c22f..ee5a4429333 100644 --- a/widget/android/nsAppShell.cpp +++ b/widget/android/nsAppShell.cpp @@ -510,9 +510,9 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait) nsresult rv = cmdline->Init(4, argv, nullptr, nsICommandLine::STATE_REMOTE_AUTO); if (NS_SUCCEEDED(rv)) cmdline->Run(); - nsMemory::Free(uri); + free(uri); if (flag) - nsMemory::Free(flag); + free(flag); break; } diff --git a/widget/cocoa/nsClipboard.mm b/widget/cocoa/nsClipboard.mm index b43b42f73e2..e701898d146 100644 --- a/widget/cocoa/nsClipboard.mm +++ b/widget/cocoa/nsClipboard.mm @@ -439,7 +439,7 @@ nsClipboard::PasteboardDictFromTransferable(nsITransferable* aTransferable) [pasteboardOutputDict setObject:nativeString forKey:pboardType]; - nsMemory::Free(data); + free(data); } else if (flavorStr.EqualsLiteral(kPNGImageMime) || flavorStr.EqualsLiteral(kJPEGImageMime) || flavorStr.EqualsLiteral(kJPGImageMime) || flavorStr.EqualsLiteral(kGIFImageMime) || diff --git a/widget/gtk/nsClipboard.cpp b/widget/gtk/nsClipboard.cpp index 1706b803a3a..0e7ea107fc9 100644 --- a/widget/gtk/nsClipboard.cpp +++ b/widget/gtk/nsClipboard.cpp @@ -331,7 +331,7 @@ nsClipboard::GetData(nsITransferable *aTransferable, int32_t aWhichClipboard) data = (guchar *)htmlBody; length = htmlBodyLen * 2; } else { - data = (guchar *)nsMemory::Alloc(length); + data = (guchar *)moz_xmalloc(length); if (!data) break; memcpy(data, clipboardData, length); @@ -354,7 +354,7 @@ nsClipboard::GetData(nsITransferable *aTransferable, int32_t aWhichClipboard) } if (data) - nsMemory::Free(data); + free(data); return NS_OK; } @@ -547,7 +547,7 @@ nsClipboard::SelectionGetEvent(GtkClipboard *aClipboard, gtk_selection_data_set_text (aSelectionData, utf8string, strlen(utf8string)); - nsMemory::Free(utf8string); + free(utf8string); return; } @@ -609,13 +609,13 @@ nsClipboard::SelectionGetEvent(GtkClipboard *aClipboard, * detect mozilla use UCS2 encoding when copy-paste. */ guchar *buffer = (guchar *) - nsMemory::Alloc((len * sizeof(guchar)) + sizeof(char16_t)); + moz_xmalloc((len * sizeof(guchar)) + sizeof(char16_t)); if (!buffer) return; char16_t prefix = 0xFEFF; memcpy(buffer, &prefix, sizeof(prefix)); memcpy(buffer + sizeof(prefix), primitive_data, len); - nsMemory::Free((guchar *)primitive_data); + free((guchar *)primitive_data); primitive_data = (guchar *)buffer; len += sizeof(prefix); } @@ -623,7 +623,7 @@ nsClipboard::SelectionGetEvent(GtkClipboard *aClipboard, gtk_selection_data_set(aSelectionData, selectionTarget, 8, /* 8 bits in a unit */ (const guchar *)primitive_data, len); - nsMemory::Free(primitive_data); + free(primitive_data); } g_free(target_name); @@ -691,7 +691,7 @@ void ConvertHTMLtoUCS2(guchar * data, int32_t dataLength, if (charset.EqualsLiteral("UTF-16")) {//current mozilla outUnicodeLen = (dataLength / 2) - 1; *unicodeData = reinterpret_cast - (nsMemory::Alloc((outUnicodeLen + sizeof('\0')) * + (moz_xmalloc((outUnicodeLen + sizeof('\0')) * sizeof(char16_t))); if (*unicodeData) { memcpy(*unicodeData, data + sizeof(char16_t), @@ -720,7 +720,7 @@ void ConvertHTMLtoUCS2(guchar * data, int32_t dataLength, // |outUnicodeLen| is number of chars if (outUnicodeLen) { *unicodeData = reinterpret_cast - (nsMemory::Alloc((outUnicodeLen + sizeof('\0')) * + (moz_xmalloc((outUnicodeLen + sizeof('\0')) * sizeof(char16_t))); if (*unicodeData) { int32_t numberTmp = dataLength; diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index 06dac2ab38b..d397aec01ee 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -3925,7 +3925,7 @@ nsWindow::SetWindowClass(const nsAString &xulWinType) if (GDK_IS_X11_DISPLAY(display)) { XClassHint *class_hint = XAllocClassHint(); if (!class_hint) { - nsMemory::Free(res_name); + free(res_name); return NS_ERROR_OUT_OF_MEMORY; } class_hint->res_name = res_name; @@ -3940,7 +3940,7 @@ nsWindow::SetWindowClass(const nsAString &xulWinType) } #endif /* MOZ_X11 */ - nsMemory::Free(res_name); + free(res_name); return NS_OK; } diff --git a/widget/nsPrimitiveHelpers.cpp b/widget/nsPrimitiveHelpers.cpp index b1ffd7dc9bb..2683543bdc4 100644 --- a/widget/nsPrimitiveHelpers.cpp +++ b/widget/nsPrimitiveHelpers.cpp @@ -210,7 +210,7 @@ nsPrimitiveHelpers :: ConvertPlatformPlainTextToUnicode ( const char* inText, in // the conversion. decoder->GetMaxLength(inText, inTextLen, outUnicodeLen); // |outUnicodeLen| is number of chars if ( *outUnicodeLen ) { - *outUnicode = reinterpret_cast(nsMemory::Alloc((*outUnicodeLen + 1) * sizeof(char16_t))); + *outUnicode = reinterpret_cast(moz_xmalloc((*outUnicodeLen + 1) * sizeof(char16_t))); if ( *outUnicode ) { rv = decoder->Convert(inText, &inTextLen, *outUnicode, outUnicodeLen); (*outUnicode)[*outUnicodeLen] = '\0'; // null terminate. Convert() doesn't do it for us @@ -251,7 +251,7 @@ nsLinebreakHelpers :: ConvertPlatformToDOMLinebreaks ( const char* inFlavor, voi *ioLengthInBytes, ioLengthInBytes ); if ( NS_SUCCEEDED(retVal) ) { if ( buffAsChars != oldBuffer ) // check if buffer was reallocated - nsMemory::Free ( oldBuffer ); + free ( oldBuffer ); *ioData = buffAsChars; } } @@ -267,7 +267,7 @@ nsLinebreakHelpers :: ConvertPlatformToDOMLinebreaks ( const char* inFlavor, voi *ioLengthInBytes / sizeof(char16_t), &newLengthInChars ); if ( NS_SUCCEEDED(retVal) ) { if ( buffAsUnichar != oldBuffer ) // check if buffer was reallocated - nsMemory::Free ( oldBuffer ); + free ( oldBuffer ); *ioData = buffAsUnichar; *ioLengthInBytes = newLengthInChars * sizeof(char16_t); } diff --git a/widget/nsTransferable.cpp b/widget/nsTransferable.cpp index 08af4ed4e02..69a619cbe63 100644 --- a/widget/nsTransferable.cpp +++ b/widget/nsTransferable.cpp @@ -152,7 +152,7 @@ DataStruct::WriteCache(nsISupports* aData, uint32_t aDataLen) if ( buff ) { uint32_t ignored; outStr->Write(reinterpret_cast(buff), aDataLen, &ignored); - nsMemory::Free(buff); + free(buff); return NS_OK; } } diff --git a/widget/qt/nsClipboard.cpp b/widget/qt/nsClipboard.cpp index 5939a43007b..dfac48e4eff 100644 --- a/widget/qt/nsClipboard.cpp +++ b/widget/qt/nsClipboard.cpp @@ -223,7 +223,7 @@ nsClipboard::SetNativeClipboardData( nsITransferable *aTransferable, QByteArray data ((const char *)primitive_data, len); // Add data to the mimeData mimeData->setData(flavorStr.get(), data); - nsMemory::Free(primitive_data); + free(primitive_data); } } } diff --git a/widget/qt/nsWindow.cpp b/widget/qt/nsWindow.cpp index b5572f452d3..3248932b91c 100644 --- a/widget/qt/nsWindow.cpp +++ b/widget/qt/nsWindow.cpp @@ -1725,7 +1725,7 @@ nsWindow::SetWindowClass(const nsAString &xulWinType) } class_hint->res_class = ToNewCString(brandName); if (!class_hint->res_class) { - nsMemory::Free(class_hint->res_name); + free(class_hint->res_name); XFree(class_hint); return NS_ERROR_OUT_OF_MEMORY; } @@ -1753,8 +1753,8 @@ nsWindow::SetWindowClass(const nsAString &xulWinType) class_hint); } - nsMemory::Free(class_hint->res_class); - nsMemory::Free(class_hint->res_name); + free(class_hint->res_class); + free(class_hint->res_name); XFree(class_hint); #endif diff --git a/widget/windows/nsClipboard.cpp b/widget/windows/nsClipboard.cpp index 9d5850e4e7f..5a8f4fa149e 100644 --- a/widget/windows/nsClipboard.cpp +++ b/widget/windows/nsClipboard.cpp @@ -282,7 +282,7 @@ nsresult nsClipboard::GetGlobalData(HGLOBAL aHGBL, void ** aData, uint32_t * aLe if (aHGBL != nullptr) { LPSTR lpStr = (LPSTR) GlobalLock(aHGBL); DWORD allocSize = GlobalSize(aHGBL); - char* data = static_cast(nsMemory::Alloc(allocSize + sizeof(char16_t))); + char* data = static_cast(moz_xmalloc(allocSize + sizeof(char16_t))); if ( data ) { memcpy ( data, lpStr, allocSize ); data[allocSize] = data[allocSize + 1] = '\0'; // null terminate for safety @@ -494,7 +494,7 @@ nsresult nsClipboard::GetNativeDataOffClipboard(IDataObject * aDataObject, UINT NS_ASSERTION ( aIndex < numFiles, "Asked for a file index out of range of list" ); if (numFiles > 0) { UINT fileNameLen = ::DragQueryFileW(dropFiles, aIndex, nullptr, 0); - wchar_t* buffer = reinterpret_cast(nsMemory::Alloc((fileNameLen + 1) * sizeof(wchar_t))); + wchar_t* buffer = reinterpret_cast(moz_xmalloc((fileNameLen + 1) * sizeof(wchar_t))); if ( buffer ) { ::DragQueryFileW(dropFiles, aIndex, buffer, fileNameLen + 1); *aData = buffer; @@ -639,7 +639,7 @@ nsresult nsClipboard::GetDataFromDataObject(IDataObject * aDataObject, nsCOMPtr file; if ( NS_SUCCEEDED(NS_NewLocalFile(filepath, false, getter_AddRefs(file))) ) genericDataWrapper = do_QueryInterface(file); - nsMemory::Free(data); + free(data); } else if ( strcmp(flavorStr, kNativeHTMLMime) == 0) { // the editor folks want CF_HTML exactly as it's on the clipboard, no conversions, @@ -649,10 +649,10 @@ nsresult nsClipboard::GetDataFromDataObject(IDataObject * aDataObject, nsPrimitiveHelpers::CreatePrimitiveForData ( flavorStr, data, dataLen, getter_AddRefs(genericDataWrapper) ); else { - nsMemory::Free(data); + free(data); continue; // something wrong with this flavor, keep looking for other data } - nsMemory::Free(data); + free(data); } else if ( strcmp(flavorStr, kJPEGImageMime) == 0 || strcmp(flavorStr, kJPGImageMime) == 0 || @@ -669,7 +669,7 @@ nsresult nsClipboard::GetDataFromDataObject(IDataObject * aDataObject, dataLen = signedLen; nsPrimitiveHelpers::CreatePrimitiveForData ( flavorStr, data, dataLen, getter_AddRefs(genericDataWrapper) ); - nsMemory::Free(data); + free(data); } NS_ASSERTION ( genericDataWrapper, "About to put null data into the transferable" ); @@ -765,7 +765,7 @@ nsClipboard :: FindUnicodeFromPlainText ( IDataObject* inDataObject, UINT inInde &convertedText, &convertedTextLen ); if ( convertedText ) { // out with the old, in with the new - nsMemory::Free(*outData); + free(*outData); *outData = convertedText; *outDataLen = convertedTextLen * sizeof(char16_t); dataFound = true; @@ -797,12 +797,12 @@ nsClipboard :: FindURLFromLocalFile ( IDataObject* inDataObject, UINT inIndex, v nsCOMPtr file; nsresult rv = NS_NewLocalFile(filepath, true, getter_AddRefs(file)); if (NS_FAILED(rv)) { - nsMemory::Free(*outData); + free(*outData); return dataFound; } if ( IsInternetShortcut(filepath) ) { - nsMemory::Free(*outData); + free(*outData); nsAutoCString url; ResolveShortcut( file, url ); if ( !url.IsEmpty() ) { @@ -828,7 +828,7 @@ nsClipboard :: FindURLFromLocalFile ( IDataObject* inDataObject, UINT inIndex, v NS_GetURLSpecFromFile(file, urlSpec); // convert it to unicode and pass it out - nsMemory::Free(*outData); + free(*outData); *outData = UTF8ToNewUnicode(urlSpec); *outDataLen = NS_strlen(static_cast(*outData)) * sizeof(char16_t); dataFound = true; @@ -861,7 +861,7 @@ nsClipboard :: FindURLFromNativeURL ( IDataObject* inDataObject, UINT inIndex, v // just repeat the URL to fake it. *outData = ToNewUnicode(urlString + NS_LITERAL_STRING("\n") + urlString); *outDataLen = NS_strlen(static_cast(*outData)) * sizeof(char16_t); - nsMemory::Free(tempOutData); + free(tempOutData); dataFound = true; } else { @@ -883,7 +883,7 @@ nsClipboard :: FindURLFromNativeURL ( IDataObject* inDataObject, UINT inIndex, v // just repeat the URL to fake it. *outData = ToNewUnicode(urlString + NS_LITERAL_STRING("\n") + urlString); *outDataLen = NS_strlen(static_cast(*outData)) * sizeof(char16_t); - nsMemory::Free(tempOutData); + free(tempOutData); dataFound = true; } } diff --git a/widget/windows/nsDataObj.cpp b/widget/windows/nsDataObj.cpp index 44c4865f806..fd3441032a7 100644 --- a/widget/windows/nsDataObj.cpp +++ b/widget/windows/nsDataObj.cpp @@ -1292,18 +1292,18 @@ HRESULT nsDataObj::GetText(const nsACString & aDataFlavor, FORMATETC& aFE, STGME // Someone is asking for text/plain; convert the unicode (assuming it's present) // to text with the correct platform encoding. size_t bufferSize = sizeof(char)*(len + 2); - char* plainTextData = static_cast(nsMemory::Alloc(bufferSize)); + char* plainTextData = static_cast(moz_xmalloc(bufferSize)); char16_t* castedUnicode = reinterpret_cast(data); int32_t plainTextLen = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)castedUnicode, len / 2 + 1, plainTextData, bufferSize, NULL, NULL); // replace the unicode data with our plaintext data. Recall that |plainTextLen| doesn't include // the null in the length. - nsMemory::Free(data); + free(data); if ( plainTextLen ) { data = plainTextData; allocLen = plainTextLen; } else { - nsMemory::Free(plainTextData); + free(plainTextData); NS_WARNING ( "Oh no, couldn't convert unicode to plain text" ); return S_OK; } @@ -1315,7 +1315,7 @@ HRESULT nsDataObj::GetText(const nsACString & aDataFlavor, FORMATETC& aFE, STGME char* utf8HTML = nullptr; nsresult rv = BuildPlatformHTML ( converter.get(), &utf8HTML ); // null terminates - nsMemory::Free(data); + free(data); if ( NS_SUCCEEDED(rv) && utf8HTML ) { // replace the unicode data with our HTML data. Don't forget the null. data = utf8HTML; @@ -1344,7 +1344,7 @@ HRESULT nsDataObj::GetText(const nsACString & aDataFlavor, FORMATETC& aFE, STGME aSTG.hGlobal = hGlobalMemory; // Now, delete the memory that was created by CreateDataFromPrimitive (or our text/plain data) - nsMemory::Free(data); + free(data); return S_OK; } diff --git a/widget/windows/nsNativeDragTarget.cpp b/widget/windows/nsNativeDragTarget.cpp index 01345338a2e..516fa64f9aa 100644 --- a/widget/windows/nsNativeDragTarget.cpp +++ b/widget/windows/nsNativeDragTarget.cpp @@ -253,7 +253,7 @@ nsNativeDragTarget::DragEnter(LPDATAOBJECT pIDataSource, pIDataSource, 0, ::RegisterClipboardFormat(CFSTR_PREFERREDDROPEFFECT), nullptr, &tempOutData, &tempDataLen); if (NS_SUCCEEDED(loadResult) && tempOutData) { mEffectsPreferred = *((DWORD*)tempOutData); - nsMemory::Free(tempOutData); + free(tempOutData); } else { // We have no preference if we can't obtain it mEffectsPreferred = DROPEFFECT_NONE; diff --git a/widget/windows/nsPrintSettingsWin.cpp b/widget/windows/nsPrintSettingsWin.cpp index f9ed18ac3e9..bf87c9c422c 100644 --- a/widget/windows/nsPrintSettingsWin.cpp +++ b/widget/windows/nsPrintSettingsWin.cpp @@ -40,8 +40,8 @@ nsPrintSettingsWin::nsPrintSettingsWin(const nsPrintSettingsWin& aPS) : */ nsPrintSettingsWin::~nsPrintSettingsWin() { - if (mDeviceName) nsMemory::Free(mDeviceName); - if (mDriverName) nsMemory::Free(mDriverName); + if (mDeviceName) free(mDeviceName); + if (mDriverName) free(mDriverName); if (mDevMode) ::HeapFree(::GetProcessHeap(), 0, mDevMode); } @@ -49,7 +49,7 @@ nsPrintSettingsWin::~nsPrintSettingsWin() NS_IMETHODIMP nsPrintSettingsWin::SetDeviceName(const char16_t * aDeviceName) { if (mDeviceName) { - nsMemory::Free(mDeviceName); + free(mDeviceName); } mDeviceName = aDeviceName?wcsdup(char16ptr_t(aDeviceName)):nullptr; return NS_OK; @@ -65,7 +65,7 @@ NS_IMETHODIMP nsPrintSettingsWin::GetDeviceName(char16_t **aDeviceName) NS_IMETHODIMP nsPrintSettingsWin::SetDriverName(const char16_t * aDriverName) { if (mDriverName) { - nsMemory::Free(mDriverName); + free(mDriverName); } mDriverName = aDriverName?wcsdup(char16ptr_t(aDriverName)):nullptr; return NS_OK; diff --git a/xpcom/base/nsConsoleService.cpp b/xpcom/base/nsConsoleService.cpp index 3dd9dc58522..cc9c385d780 100644 --- a/xpcom/base/nsConsoleService.cpp +++ b/xpcom/base/nsConsoleService.cpp @@ -71,7 +71,7 @@ nsConsoleService::~nsConsoleService() } if (mMessages) { - nsMemory::Free(mMessages); + free(mMessages); } } @@ -100,7 +100,7 @@ nsresult nsConsoleService::Init() { mMessages = (nsIConsoleMessage**) - nsMemory::Alloc(mBufferSize * sizeof(nsIConsoleMessage*)); + moz_xmalloc(mBufferSize * sizeof(nsIConsoleMessage*)); if (!mMessages) { return NS_ERROR_OUT_OF_MEMORY; } @@ -332,7 +332,7 @@ nsConsoleService::GetMessageArray(uint32_t* aCount, * array object when called from script. */ messageArray = (nsIConsoleMessage**) - nsMemory::Alloc(sizeof(nsIConsoleMessage*)); + moz_xmalloc(sizeof(nsIConsoleMessage*)); *messageArray = nullptr; *aMessages = messageArray; *aCount = 0; @@ -342,7 +342,7 @@ nsConsoleService::GetMessageArray(uint32_t* aCount, uint32_t resultSize = mFull ? mBufferSize : mCurrent; messageArray = - (nsIConsoleMessage**)nsMemory::Alloc((sizeof(nsIConsoleMessage*)) + (nsIConsoleMessage**)moz_xmalloc((sizeof(nsIConsoleMessage*)) * resultSize); if (!messageArray) { diff --git a/xpcom/ds/nsProperties.cpp b/xpcom/ds/nsProperties.cpp index f6a3a6bf6df..40b7bcd7fec 100644 --- a/xpcom/ds/nsProperties.cpp +++ b/xpcom/ds/nsProperties.cpp @@ -94,7 +94,7 @@ nsProperties::GetKeys(uint32_t* aCount, char*** aKeys) } uint32_t n = Count(); - char** k = (char**)nsMemory::Alloc(n * sizeof(char*)); + char** k = (char**)moz_xmalloc(n * sizeof(char*)); GetKeysEnumData gked; gked.keys = k; @@ -107,9 +107,9 @@ nsProperties::GetKeys(uint32_t* aCount, char*** aKeys) if (NS_FAILED(rv)) { // Free 'em all for (uint32_t i = 0; i < gked.next; i++) { - nsMemory::Free(k[i]); + free(k[i]); } - nsMemory::Free(k); + free(k); return rv; } diff --git a/xpcom/ds/nsStaticNameTable.cpp b/xpcom/ds/nsStaticNameTable.cpp index aa95c23464b..0f5fa6e8d2c 100644 --- a/xpcom/ds/nsStaticNameTable.cpp +++ b/xpcom/ds/nsStaticNameTable.cpp @@ -115,7 +115,7 @@ nsStaticCaseInsensitiveNameTable::~nsStaticCaseInsensitiveNameTable() for (uint32_t index = 0; index < mNameTable.EntryCount(); index++) { mNameArray[index].~nsDependentCString(); } - nsMemory::Free((void*)mNameArray); + free((void*)mNameArray); } if (mNameTable.IsInitialized()) { PL_DHashTableFinish(&mNameTable); @@ -133,7 +133,7 @@ nsStaticCaseInsensitiveNameTable::Init(const char* const aNames[], NS_ASSERTION(aLength, "0 length"); mNameArray = (nsDependentCString*) - nsMemory::Alloc(aLength * sizeof(nsDependentCString)); + moz_xmalloc(aLength * sizeof(nsDependentCString)); if (!mNameArray) { return false; } diff --git a/xpcom/ds/nsSupportsPrimitives.cpp b/xpcom/ds/nsSupportsPrimitives.cpp index 34235ce8f47..737f1e01824 100644 --- a/xpcom/ds/nsSupportsPrimitives.cpp +++ b/xpcom/ds/nsSupportsPrimitives.cpp @@ -41,7 +41,7 @@ NS_IMETHODIMP nsSupportsIDImpl::SetData(const nsID* aData) { if (mData) { - nsMemory::Free(mData); + free(mData); } if (aData) { mData = (nsID*)nsMemory::Clone(aData, sizeof(nsID)); @@ -469,7 +469,7 @@ nsSupportsCharImpl::ToString(char** aResult) { NS_ASSERTION(aResult, "Bad pointer"); - char* result = (char*)nsMemory::Alloc(2 * sizeof(char)); + char* result = (char*)moz_xmalloc(2 * sizeof(char)); if (result) { result[0] = mData; result[1] = '\0'; @@ -769,7 +769,7 @@ nsSupportsInterfacePointerImpl::nsSupportsInterfacePointerImpl() nsSupportsInterfacePointerImpl::~nsSupportsInterfacePointerImpl() { if (mIID) { - nsMemory::Free(mIID); + free(mIID); } } @@ -818,7 +818,7 @@ NS_IMETHODIMP nsSupportsInterfacePointerImpl::SetDataIID(const nsID* aIID) { if (mIID) { - nsMemory::Free(mIID); + free(mIID); } if (aIID) { mIID = (nsID*)nsMemory::Clone(aIID, sizeof(nsID)); diff --git a/xpcom/ds/nsVariant.cpp b/xpcom/ds/nsVariant.cpp index ebf6f0381db..6f1ee9cf2c3 100644 --- a/xpcom/ds/nsVariant.cpp +++ b/xpcom/ds/nsVariant.cpp @@ -40,7 +40,7 @@ AString2Double(const nsAString& aString, double* aResult) return NS_ERROR_OUT_OF_MEMORY; } nsresult rv = String2Double(pChars, aResult); - nsMemory::Free(pChars); + free(pChars); return rv; } @@ -180,7 +180,7 @@ FreeArray(nsDiscriminatedUnion* aData) ctype_ ** p = (ctype_ **) aData->u.array.mArrayValue; \ for(uint32_t i = aData->u.array.mArrayCount; i > 0; p++, i--) \ if(*p) \ - nsMemory::Free((char*)*p); \ + free((char*)*p); \ break; \ } @@ -234,7 +234,7 @@ FreeArray(nsDiscriminatedUnion* aData) } // Free the array memory. - nsMemory::Free((char*)aData->u.array.mArrayValue); + free((char*)aData->u.array.mArrayValue); #undef CASE__FREE_ARRAY_PTR #undef CASE__FREE_ARRAY_IFACE @@ -331,7 +331,7 @@ CloneArray(uint16_t aInType, const nsIID* aInIID, // Alloc the u.array. allocSize = aInCount * elementSize; - *aOutValue = nsMemory::Alloc(allocSize); + *aOutValue = moz_xmalloc(allocSize); if (!*aOutValue) { return NS_ERROR_OUT_OF_MEMORY; } @@ -450,9 +450,9 @@ bad: char** p = (char**)*aOutValue; for (i = allocatedValueCount; i > 0; ++p, --i) if (*p) { - nsMemory::Free(*p); + free(*p); } - nsMemory::Free((char*)*aOutValue); + free((char*)*aOutValue); *aOutValue = nullptr; } return rv; @@ -710,7 +710,7 @@ String2ID(const nsDiscriminatedUnion& aData, nsID* aPid) return false; } bool result = aPid->Parse(pChars); - nsMemory::Free(pChars); + free(pChars); return result; } @@ -791,7 +791,7 @@ ToString(const nsDiscriminatedUnion& aData, nsACString& aOutString) return NS_ERROR_OUT_OF_MEMORY; } aOutString.Assign(ptr); - nsMemory::Free(ptr); + free(ptr); return NS_OK; // Can't use PR_smprintf for floats, since it's locale-dependent @@ -1343,7 +1343,7 @@ nsVariant::SetFromVariant(nsDiscriminatedUnion* aData, nsIVariant* aValue) rv = aValue->GetAsInterface(&iid, (void**)&aData->u.iface.mInterfaceValue); if (NS_SUCCEEDED(rv)) { aData->u.iface.mInterfaceID = *iid; - nsMemory::Free((char*)iid); + free((char*)iid); } CASE__SET_FROM_VARIANT_VTYPE_EPILOGUE(VTYPE_INTERFACE_IS) @@ -1628,11 +1628,11 @@ nsVariant::Cleanup(nsDiscriminatedUnion* aData) break; case nsIDataType::VTYPE_CHAR_STR: case nsIDataType::VTYPE_STRING_SIZE_IS: - nsMemory::Free((char*)aData->u.str.mStringValue); + free((char*)aData->u.str.mStringValue); break; case nsIDataType::VTYPE_WCHAR_STR: case nsIDataType::VTYPE_WSTRING_SIZE_IS: - nsMemory::Free((char*)aData->u.wstr.mWStringValue); + free((char*)aData->u.wstr.mWStringValue); break; case nsIDataType::VTYPE_INTERFACE: case nsIDataType::VTYPE_INTERFACE_IS: diff --git a/xpcom/glue/nsIClassInfoImpl.h b/xpcom/glue/nsIClassInfoImpl.h index 2ac5a8b3d2b..28caddc0a98 100644 --- a/xpcom/glue/nsIClassInfoImpl.h +++ b/xpcom/glue/nsIClassInfoImpl.h @@ -138,7 +138,7 @@ NS_IMETHODIMP \ NS_CI_INTERFACE_GETTER_NAME(_class)(uint32_t *count, nsIID ***array) \ { \ *count = _c; \ - *array = (nsIID **)nsMemory::Alloc(sizeof (nsIID *) * _c); \ + *array = (nsIID **)moz_xmalloc(sizeof (nsIID *) * _c); \ uint32_t i = 0; #define NS_CLASSINFO_HELPER_ENTRY(_interface) \ diff --git a/xpcom/glue/nsMemory.h b/xpcom/glue/nsMemory.h index bfbc8f74297..ac3495fb9ab 100644 --- a/xpcom/glue/nsMemory.h +++ b/xpcom/glue/nsMemory.h @@ -55,7 +55,7 @@ public: /** * Macro to free all elements of an XPCOM array of a given size using - * freeFunc, then frees the array itself using nsMemory::Free(). + * freeFunc, then frees the array itself using free(). * * Note that this macro (and its wrappers) can be used to deallocate a * partially- or completely-built array while unwinding an error @@ -67,7 +67,7 @@ public: * * Thanks to for suggesting this form, which * allows the macro to be used with NS_RELEASE / NS_RELEASE_IF in - * addition to nsMemory::Free. + * addition to free. * * @param size Number of elements in the array. If not a constant, this * should be a int32_t. Note that this means this macro @@ -78,9 +78,7 @@ public: * from it), NS_IF_RELEASE (or NS_RELEASE) should be * passed as freeFunc. For most (all?) other pointer * types (including XPCOM strings and wstrings), - * nsMemory::Free should be used, since the - * shared-allocator (nsMemory) is what will have been - * used to allocate the memory. + * free should be used. */ #define NS_FREE_XPCOM_POINTER_ARRAY(size, array, freeFunc) \ PR_BEGIN_MACRO \ diff --git a/xpcom/glue/nsTextFormatter.cpp b/xpcom/glue/nsTextFormatter.cpp index b95a09121a5..dc9e7bfd633 100644 --- a/xpcom/glue/nsTextFormatter.cpp +++ b/xpcom/glue/nsTextFormatter.cpp @@ -603,7 +603,7 @@ BuildArgArray(const char16_t* aFmt, va_list aAp, int* aRv, } if (number > NAS_DEFAULT_NUM) { - nas = (struct NumArgState*)nsMemory::Alloc(number * sizeof(struct NumArgState)); + nas = (struct NumArgState*)moz_xmalloc(number * sizeof(struct NumArgState)); if (!nas) { *aRv = -1; return nullptr; @@ -1203,10 +1203,10 @@ GrowStuff(SprintfState* aState, const char16_t* aStr, uint32_t aLen) /* Grow the buffer */ newlen = aState->maxlen + ((aLen > 32) ? aLen : 32); if (aState->base) { - newbase = (char16_t*)nsMemory::Realloc(aState->base, - newlen * sizeof(char16_t)); + newbase = (char16_t*)moz_xrealloc(aState->base, + newlen * sizeof(char16_t)); } else { - newbase = (char16_t*)nsMemory::Alloc(newlen * sizeof(char16_t)); + newbase = (char16_t*)moz_xmalloc(newlen * sizeof(char16_t)); } if (!newbase) { /* Ran out of memory */ @@ -1361,6 +1361,6 @@ nsTextFormatter::vsnprintf(char16_t* aOut, uint32_t aOutLen, void nsTextFormatter::smprintf_free(char16_t* aMem) { - nsMemory::Free(aMem); + free(aMem); } diff --git a/xpcom/glue/nsTextFormatter.h b/xpcom/glue/nsTextFormatter.h index c8fb3deec49..4cd44be320e 100644 --- a/xpcom/glue/nsTextFormatter.h +++ b/xpcom/glue/nsTextFormatter.h @@ -53,7 +53,7 @@ public: const char16_t* aFmt, ...); /* - * sprintf into a nsMemory::Alloc'd buffer. Return a pointer to + * sprintf into a moz_xmalloc'd buffer. Return a pointer to * buffer on success, nullptr on failure. */ static char16_t* smprintf(const char16_t* aFmt, ...); @@ -71,7 +71,7 @@ public: /* * Free the memory allocated, for the caller, by smprintf. * -- Deprecated -- - * Callers can substitute calling smprintf_free with nsMemory::Free + * Callers can substitute calling smprintf_free with free */ static void smprintf_free(char16_t* aMem); diff --git a/xpcom/io/nsEscape.cpp b/xpcom/io/nsEscape.cpp index ae097ac82ec..8042d97974b 100644 --- a/xpcom/io/nsEscape.cpp +++ b/xpcom/io/nsEscape.cpp @@ -104,14 +104,14 @@ 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 nsMemory::Alloc(size_t) + // 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 nsMemory::Alloc() + // no chance to allocate more than 4GB using moz_xmalloc() if (dstSize > UINT32_MAX) { return 0; } - char* result = (char*)nsMemory::Alloc(dstSize); + char* result = (char*)moz_xmalloc(dstSize); if (!result) { return 0; } @@ -291,7 +291,7 @@ nsEscapeHTML2(const char16_t* aSourceBuffer, int32_t aSourceBufferLen) return nullptr; } - char16_t* resultBuffer = (char16_t*)nsMemory::Alloc( + char16_t* resultBuffer = (char16_t*)moz_xmalloc( aSourceBufferLen * 6 * sizeof(char16_t) + sizeof(char16_t('\0'))); char16_t* ptr = resultBuffer; diff --git a/xpcom/io/nsIStringStream.idl b/xpcom/io/nsIStringStream.idl index fec418a4f42..e364627276e 100644 --- a/xpcom/io/nsIStringStream.idl +++ b/xpcom/io/nsIStringStream.idl @@ -37,7 +37,7 @@ interface nsIStringInputStream : nsIInputStream /** * AdoptData - assign data to the input stream. the input stream takes - * ownership of the given data buffer and will nsMemory::Free it when + * ownership of the given data buffer and will free it when * the input stream is destroyed. * * @param data - stream data diff --git a/xpcom/io/nsLinebreakConverter.cpp b/xpcom/io/nsLinebreakConverter.cpp index dc86c0a8397..8dbc0dcb9a0 100644 --- a/xpcom/io/nsLinebreakConverter.cpp +++ b/xpcom/io/nsLinebreakConverter.cpp @@ -100,7 +100,7 @@ ConvertBreaks(const T* aInSrc, int32_t& aIoLen, const char* aSrcBreak, // handle the no conversion case if (nsCRT::strcmp(aSrcBreak, aDestBreak) == 0) { - resultString = (T*)nsMemory::Alloc(sizeof(T) * aIoLen); + resultString = (T*)moz_xmalloc(sizeof(T) * aIoLen); if (!resultString) { return nullptr; } @@ -114,7 +114,7 @@ ConvertBreaks(const T* aInSrc, int32_t& aIoLen, const char* aSrcBreak, // handle the easy case, where the string length does not change, and the // breaks are only 1 char long, i.e. CR <-> LF if (srcBreakLen == destBreakLen && srcBreakLen == 1) { - resultString = (T*)nsMemory::Alloc(sizeof(T) * aIoLen); + resultString = (T*)moz_xmalloc(sizeof(T) * aIoLen); if (!resultString) { return nullptr; } @@ -144,7 +144,7 @@ ConvertBreaks(const T* aInSrc, int32_t& aIoLen, const char* aSrcBreak, int32_t newBufLen = aIoLen - (numLinebreaks * srcBreakLen) + (numLinebreaks * destBreakLen); - resultString = (T*)nsMemory::Alloc(sizeof(T) * newBufLen); + resultString = (T*)moz_xmalloc(sizeof(T) * newBufLen); if (!resultString) { return nullptr; } @@ -235,7 +235,7 @@ ConvertUnknownBreaks(const T* aInSrc, int32_t& aIoLen, const char* aDestBreak) src++; } - T* resultString = (T*)nsMemory::Alloc(sizeof(T) * finalLen); + T* resultString = (T*)moz_xmalloc(sizeof(T) * finalLen); if (!resultString) { return nullptr; } diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp index 1aea074f549..826573daa5d 100644 --- a/xpcom/io/nsLocalFileUnix.cpp +++ b/xpcom/io/nsLocalFileUnix.cpp @@ -1765,13 +1765,13 @@ nsLocalFile::GetNativeTarget(nsACString& aResult) } int32_t size = (int32_t)symStat.st_size; - char* target = (char*)nsMemory::Alloc(size + 1); + char* target = (char*)moz_xmalloc(size + 1); if (!target) { return NS_ERROR_OUT_OF_MEMORY; } if (readlink(mPath.get(), target, (size_t)size) < 0) { - nsMemory::Free(target); + free(target); return NSRESULT_FOR_ERRNO(); } target[size] = '\0'; @@ -1816,7 +1816,7 @@ nsLocalFile::GetNativeTarget(nsACString& aResult) int32_t newSize = (int32_t)symStat.st_size; if (newSize > size) { - char* newTarget = (char*)nsMemory::Realloc(target, newSize + 1); + char* newTarget = (char*)moz_xrealloc(target, newSize + 1); if (!newTarget) { rv = NS_ERROR_OUT_OF_MEMORY; break; @@ -1833,7 +1833,7 @@ nsLocalFile::GetNativeTarget(nsACString& aResult) target[linkLen] = '\0'; } - nsMemory::Free(target); + free(target); if (NS_FAILED(rv)) { aResult.Truncate(); diff --git a/xpcom/io/nsScriptableInputStream.cpp b/xpcom/io/nsScriptableInputStream.cpp index ba50edd6316..c0e7c5b72e0 100644 --- a/xpcom/io/nsScriptableInputStream.cpp +++ b/xpcom/io/nsScriptableInputStream.cpp @@ -65,7 +65,7 @@ nsScriptableInputStream::Read(uint32_t aCount, char** aResult) rv = ReadHelper(buffer, count); if (NS_FAILED(rv)) { - nsMemory::Free(buffer); + free(buffer); return rv; } diff --git a/xpcom/io/nsSegmentedBuffer.cpp b/xpcom/io/nsSegmentedBuffer.cpp index 487333f3b39..ab42a73c72e 100644 --- a/xpcom/io/nsSegmentedBuffer.cpp +++ b/xpcom/io/nsSegmentedBuffer.cpp @@ -32,7 +32,7 @@ nsSegmentedBuffer::AppendNewSegment() if (!mSegmentArray) { uint32_t bytes = mSegmentArrayCount * sizeof(char*); - mSegmentArray = (char**)nsMemory::Alloc(bytes); + mSegmentArray = (char**)moz_xmalloc(bytes); if (!mSegmentArray) { return nullptr; } @@ -42,7 +42,7 @@ nsSegmentedBuffer::AppendNewSegment() if (IsFull()) { uint32_t newArraySize = mSegmentArrayCount * 2; uint32_t bytes = newArraySize * sizeof(char*); - char** newSegArray = (char**)nsMemory::Realloc(mSegmentArray, bytes); + char** newSegArray = (char**)moz_xrealloc(mSegmentArray, bytes); if (!newSegArray) { return nullptr; } @@ -122,7 +122,7 @@ nsSegmentedBuffer::Empty() free(mSegmentArray[i]); } } - nsMemory::Free(mSegmentArray); + free(mSegmentArray); mSegmentArray = nullptr; } mSegmentArrayCount = NS_SEGMENTARRAY_INITIAL_COUNT; diff --git a/xpcom/reflect/xptcall/tests/TestXPTCInvoke.cpp b/xpcom/reflect/xptcall/tests/TestXPTCInvoke.cpp index 5135cc12738..0d8d391c84a 100644 --- a/xpcom/reflect/xptcall/tests/TestXPTCInvoke.cpp +++ b/xpcom/reflect/xptcall/tests/TestXPTCInvoke.cpp @@ -297,7 +297,7 @@ NS_IMETHODIMP InvokeTestTarget::PassTwoStrings(const char* s1, const char* s2, char** retval) { const char milk[] = "milk"; - char *ret = (char*)nsMemory::Alloc(sizeof(milk)); + char *ret = (char*)moz_xmalloc(sizeof(milk)); if (!ret) return NS_ERROR_OUT_OF_MEMORY; strncpy(ret, milk, sizeof(milk)); @@ -403,7 +403,7 @@ int main() if (NS_SUCCEEDED(test->PassTwoStrings("moo","cow",&outS))) { printf(" = %s\n", outS); - nsMemory::Free(outS); + free(outS); } else printf("\tFAILED"); diff --git a/xpcom/string/nsReadableUtils.cpp b/xpcom/string/nsReadableUtils.cpp index 145e3229cc4..43acc941552 100644 --- a/xpcom/string/nsReadableUtils.cpp +++ b/xpcom/string/nsReadableUtils.cpp @@ -275,7 +275,7 @@ AppendUTF8toUTF16(const char* aSource, nsAString& aDest) * A helper function that allocates a buffer of the desired character type big enough to hold a copy of the supplied string (plus a zero terminator). * * @param aSource an string you will eventually be making a copy of - * @return a new buffer (of the type specified by the second parameter) which you must free with |nsMemory::Free|. + * @return a new buffer (of the type specified by the second parameter) which you must free with |free|. * */ template @@ -283,7 +283,7 @@ inline ToCharT* AllocateStringCopy(const FromStringT& aSource, ToCharT*) { - return static_cast(nsMemory::Alloc( + return static_cast(moz_xmalloc( (aSource.Length() + 1) * sizeof(ToCharT))); } @@ -316,7 +316,7 @@ ToNewUTF8String(const nsAString& aSource, uint32_t* aUTF8Count) } char* result = static_cast - (nsMemory::Alloc(calculator.Size() + 1)); + (moz_xmalloc(calculator.Size() + 1)); if (!result) { return nullptr; } @@ -408,7 +408,7 @@ UTF8ToNewUnicode(const nsACString& aSource, uint32_t* aUTF16Count) { const uint32_t length = CalcUTF8ToUnicodeLength(aSource); const size_t buffer_size = (length + 1) * sizeof(char16_t); - char16_t* buffer = static_cast(nsMemory::Alloc(buffer_size)); + char16_t* buffer = static_cast(moz_xmalloc(buffer_size)); if (!buffer) { return nullptr; } diff --git a/xpcom/string/nsReadableUtils.h b/xpcom/string/nsReadableUtils.h index 10d5f1b2183..1d625b2baae 100644 --- a/xpcom/string/nsReadableUtils.h +++ b/xpcom/string/nsReadableUtils.h @@ -82,13 +82,13 @@ inline void AppendUTF16toUTF8(char16ptr_t aSource, nsACString& aDest) /** * Returns a new |char| buffer containing a zero-terminated copy of |aSource|. * - * Allocates and returns a new |char| buffer which you must free with |nsMemory::Free|. + * Allocates and returns a new |char| buffer which you must free with |free|. * Performs a lossy encoding conversion by chopping 16-bit wide characters down to 8-bits wide while copying |aSource| to your new buffer. * This conversion is not well defined; but it reproduces legacy string behavior. * The new buffer is zero-terminated, but that may not help you if |aSource| contains embedded nulls. * * @param aSource a 16-bit wide string - * @return a new |char| buffer you must free with |nsMemory::Free|. + * @return a new |char| buffer you must free with |free|. */ char* ToNewCString(const nsAString& aSource); @@ -96,11 +96,11 @@ char* ToNewCString(const nsAString& aSource); /** * Returns a new |char| buffer containing a zero-terminated copy of |aSource|. * - * Allocates and returns a new |char| buffer which you must free with |nsMemory::Free|. + * Allocates and returns a new |char| buffer which you must free with |free|. * The new buffer is zero-terminated, but that may not help you if |aSource| contains embedded nulls. * * @param aSource an 8-bit wide string - * @return a new |char| buffer you must free with |nsMemory::Free|. + * @return a new |char| buffer you must free with |free|. */ char* ToNewCString(const nsACString& aSource); @@ -108,7 +108,7 @@ char* ToNewCString(const nsACString& aSource); * Returns a new |char| buffer containing a zero-terminated copy of |aSource|. * * Allocates and returns a new |char| buffer which you must free with - * |nsMemory::Free|. + * |free|. * Performs an encoding conversion from a UTF-16 string to a UTF-8 string * copying |aSource| to your new buffer. * The new buffer is zero-terminated, but that may not help you if |aSource| @@ -116,7 +116,7 @@ char* ToNewCString(const nsACString& aSource); * * @param aSource a UTF-16 string (made of char16_t's) * @param aUTF8Count the number of 8-bit units that was returned - * @return a new |char| buffer you must free with |nsMemory::Free|. + * @return a new |char| buffer you must free with |free|. */ char* ToNewUTF8String(const nsAString& aSource, uint32_t* aUTF8Count = nullptr); @@ -127,12 +127,12 @@ char* ToNewUTF8String(const nsAString& aSource, uint32_t* aUTF8Count = nullptr); * |aSource|. * * Allocates and returns a new |char16_t| buffer which you must free with - * |nsMemory::Free|. + * |free|. * The new buffer is zero-terminated, but that may not help you if |aSource| * contains embedded nulls. * * @param aSource a UTF-16 string - * @return a new |char16_t| buffer you must free with |nsMemory::Free|. + * @return a new |char16_t| buffer you must free with |free|. */ char16_t* ToNewUnicode(const nsAString& aSource); @@ -140,13 +140,13 @@ char16_t* ToNewUnicode(const nsAString& aSource); /** * Returns a new |char16_t| buffer containing a zero-terminated copy of |aSource|. * - * Allocates and returns a new |char16_t| buffer which you must free with |nsMemory::Free|. + * Allocates and returns a new |char16_t| buffer which you must free with |free|. * Performs an encoding conversion by 0-padding 8-bit wide characters up to 16-bits wide while copying |aSource| to your new buffer. * This conversion is not well defined; but it reproduces legacy string behavior. * The new buffer is zero-terminated, but that may not help you if |aSource| contains embedded nulls. * * @param aSource an 8-bit wide string (a C-string, NOT UTF-8) - * @return a new |char16_t| buffer you must free with |nsMemory::Free|. + * @return a new |char16_t| buffer you must free with |free|. */ char16_t* ToNewUnicode(const nsACString& aSource); @@ -187,14 +187,14 @@ char16_t* UTF8ToUnicodeBuffer(const nsACString& aSource, * of |aSource|. * * Allocates and returns a new |char| buffer which you must free with - * |nsMemory::Free|. Performs an encoding conversion from UTF-8 to UTF-16 + * |free|. Performs an encoding conversion from UTF-8 to UTF-16 * while copying |aSource| to your new buffer. This conversion is well defined * for a valid UTF-8 string. The new buffer is zero-terminated, but that * may not help you if |aSource| contains embedded nulls. * * @param aSource an 8-bit wide string, UTF-8 encoded * @param aUTF16Count the number of 16-bit units that was returned - * @return a new |char16_t| buffer you must free with |nsMemory::Free|. + * @return a new |char16_t| buffer you must free with |free|. * (UTF-16 encoded) */ char16_t* UTF8ToNewUnicode(const nsACString& aSource, diff --git a/xpcom/string/nsSubstring.cpp b/xpcom/string/nsSubstring.cpp index a13e6d97912..5c0d75973e2 100644 --- a/xpcom/string/nsSubstring.cpp +++ b/xpcom/string/nsSubstring.cpp @@ -112,7 +112,7 @@ ReleaseData(void* aData, uint32_t aFlags) if (aFlags & nsSubstring::F_SHARED) { nsStringBuffer::FromData(aData)->Release(); } else if (aFlags & nsSubstring::F_OWNED) { - nsMemory::Free(aData); + free(aData); STRING_STAT_INCREMENT(AdoptFree); #ifdef NS_BUILD_REFCNT_LOGGING // Treat this as destruction of a "StringAdopt" object for leak diff --git a/xpcom/string/nsTSubstring.h b/xpcom/string/nsTSubstring.h index 78bd96e1ca5..495012f54b9 100644 --- a/xpcom/string/nsTSubstring.h +++ b/xpcom/string/nsTSubstring.h @@ -1106,7 +1106,7 @@ public: // buffer length. See nsStringHeader. // // "adopted buffer" An adopted buffer is a raw string buffer - // allocated on the heap (using nsMemory::Alloc) + // allocated on the heap (using moz_xmalloc) // of which the string class subsumes ownership. // // Some comments about the string flags: diff --git a/xpcom/string/nsXPCOMStrings.h b/xpcom/string/nsXPCOMStrings.h index e320ed7e031..5855bdd2948 100644 --- a/xpcom/string/nsXPCOMStrings.h +++ b/xpcom/string/nsXPCOMStrings.h @@ -238,7 +238,7 @@ XPCOM_API(uint32_t) NS_StringGetMutableData(nsAString& aStr, * * @param aStr abstract string reference * @return null-terminated copy of the string's internal buffer - * (it must be free'd using using nsMemory::Free) + * (it must be free'd using using free) */ XPCOM_API(char16_t*) NS_StringCloneData(const nsAString& aStr); @@ -534,7 +534,7 @@ XPCOM_API(uint32_t) NS_CStringGetMutableData(nsACString& aStr, * * @param aStr abstract string reference * @return null-terminated copy of the string's internal buffer - * (it must be free'd using using nsMemory::Free) + * (it must be free'd using using free) */ XPCOM_API(char*) NS_CStringCloneData(const nsACString& aStr); diff --git a/xpcom/tests/gtest/TestStrings.cpp b/xpcom/tests/gtest/TestStrings.cpp index dc5fd6fbfb4..3e364416b9b 100644 --- a/xpcom/tests/gtest/TestStrings.cpp +++ b/xpcom/tests/gtest/TestStrings.cpp @@ -131,7 +131,7 @@ TEST(Strings, findinreadable) // Should match the first "!/" but not the last EXPECT_NE(delim_end, end); EXPECT_STREQ(r, "!/"); - nsMemory::Free(r); + free(r); delim_begin = begin; delim_end = end; @@ -143,7 +143,7 @@ TEST(Strings, findinreadable) // Should not match the first jar:, but the second one EXPECT_EQ(delim_begin, begin); EXPECT_STREQ(r, "jar:"); - nsMemory::Free(r); + free(r); // Search for jar: in a Substring delim_begin = begin; delim_begin++; @@ -154,7 +154,7 @@ TEST(Strings, findinreadable) // Should not match the first jar:, but the second one EXPECT_NE(delim_begin, begin); EXPECT_STREQ(r, "jar:"); - nsMemory::Free(r); + free(r); // Should not find a match EXPECT_FALSE(FindInReadable(NS_LITERAL_CSTRING("gecko"), delim_begin, delim_end)); @@ -196,7 +196,7 @@ TEST(Strings, rfindinreadable) // Should match the last "!/" EXPECT_EQ(delim_end, end); EXPECT_STREQ(r, "!/"); - nsMemory::Free(r); + free(r); delim_begin = begin; delim_end = end; @@ -208,7 +208,7 @@ TEST(Strings, rfindinreadable) // Should not match the first jar:, but the second one EXPECT_NE(delim_begin, begin); EXPECT_STREQ(r, "jar:"); - nsMemory::Free(r); + free(r); // Search for jar: in a Substring delim_begin = begin; @@ -219,7 +219,7 @@ TEST(Strings, rfindinreadable) // Should not match the first jar:, but the second one EXPECT_EQ(delim_begin, begin); EXPECT_STREQ(r, "jar:"); - nsMemory::Free(r); + free(r); // Should not find a match delim_begin = begin; @@ -472,7 +472,7 @@ TEST(Strings, xpidl_string) a.EndReading(end); char *r = ToNewCString(Substring(begin, end)); EXPECT_STREQ(r, ""); - nsMemory::Free(r); + free(r); a.Adopt(0); EXPECT_TRUE(a.IsVoid()); diff --git a/xpfe/appshell/nsWebShellWindow.cpp b/xpfe/appshell/nsWebShellWindow.cpp index 49bfdf1c820..e795c819fb9 100644 --- a/xpfe/appshell/nsWebShellWindow.cpp +++ b/xpfe/appshell/nsWebShellWindow.cpp @@ -662,7 +662,7 @@ void nsWebShellWindow::LoadContentAreas() { nullptr, nullptr, nullptr); - nsMemory::Free(urlChar); + free(urlChar); } } }