Bug 1134920 - Use moz_xmalloc/moz_xrealloc/free instead of nsMemory::Alloc/Realloc/Free. r=nfroyd

This commit is contained in:
Mike Hommey 2015-03-27 09:01:12 +09:00
parent 64b999f2ed
commit b077d9624d
162 changed files with 481 additions and 484 deletions

View File

@ -24,7 +24,7 @@ public:
mAcceptRoles(nullptr) { }
~RuleCache () {
if (mAcceptRoles)
nsMemory::Free(mAcceptRoles);
free(mAcceptRoles);
}
nsresult ApplyFilter(Accessible* aAccessible, uint16_t* aResult);

View File

@ -173,7 +173,7 @@ public:
~ClassInfoData()
{
if (mMustFreeName)
nsMemory::Free(mName);
free(mName);
}
uint32_t GetFlags()

View File

@ -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.

View File

@ -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<nsIID **>(nsMemory::Alloc(count * sizeof(nsIID *)));
*aArray = static_cast<nsIID **>(moz_xmalloc(count * sizeof(nsIID *)));
NS_ENSURE_TRUE(*aArray, NS_ERROR_OUT_OF_MEMORY);
uint32_t i;

View File

@ -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++) {

View File

@ -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:

View File

@ -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<nsIDOMBlob> domBlob = do_QueryInterface(supports);
nsRefPtr<File> blob = static_cast<File*>(domBlob.get());

View File

@ -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;

View File

@ -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);
}

View File

@ -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);

View File

@ -317,7 +317,7 @@ public:
}
~AutoFree() {
if (mPtr)
nsMemory::Free(mPtr);
free(mPtr);
}
void Invalidate() {
mPtr = 0;

View File

@ -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) {

View File

@ -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;

View File

@ -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<nsIDOMDocument> doc = do_QueryInterface(supports);

View File

@ -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]);

View File

@ -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);
}
}

View File

@ -152,7 +152,7 @@ EventListenerService::GetListenerInfoFor(nsIDOMEventTarget* aEventTarget,
*aOutArray =
static_cast<nsIEventListenerInfo**>(
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<nsIDOMEventTarget**>(
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) {

View File

@ -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);

View File

@ -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);

View File

@ -3469,7 +3469,7 @@ nsHTMLDocument::QueryCommandState(const nsAString& commandID, ErrorResult& rv)
retval = paramToCheck.Equals(actualAlignmentType);
}
if (actualAlignmentType) {
nsMemory::Free(actualAlignmentType);
free(actualAlignmentType);
}
return retval;
}

View File

@ -439,7 +439,7 @@ MobileConnection::GetSupportedNetworkTypes(nsTArray<MobileNetworkType>& aTypes)
aTypes.AppendElement(static_cast<MobileNetworkType>(type));
}
nsMemory::Free(types);
free(types);
}
already_AddRefed<DOMRequest>

View File

@ -114,7 +114,7 @@ MobileConnectionChild::GetSupportedNetworkTypes(int32_t** aTypes,
*aLength = mSupportedNetworkTypes.Length();
*aTypes =
static_cast<int32_t*>(nsMemory::Alloc((*aLength) * sizeof(int32_t)));
static_cast<int32_t*>(moz_xmalloc((*aLength) * sizeof(int32_t)));
NS_ENSURE_TRUE(*aTypes, NS_ERROR_OUT_OF_MEMORY);
for (uint32_t i = 0; i < *aLength; i++) {

View File

@ -147,7 +147,7 @@ MobileConnectionParent::RecvInit(nsMobileConnectionInfo* aVoice,
aSupportedNetworkTypes->AppendElement(types[i]);
}
nsMemory::Free(types);
free(types);
return true;
}

View File

@ -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

View File

@ -1293,7 +1293,7 @@ nsNPAPIPluginInstance::GetFormValue(nsAString& aValue)
// NPPVformValue allocates with NPN_MemAlloc(), which uses
// nsMemory.
nsMemory::Free(value);
free(value);
return NS_OK;
}

View File

@ -1128,7 +1128,7 @@ nsPluginHost::GetPluginTags(uint32_t* aPluginCount, nsIPluginTag*** aResults)
}
*aResults = static_cast<nsIPluginTag**>
(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;

View File

@ -122,7 +122,7 @@ CStringArrayToXPCArray(nsTArray<nsCString> & aArray,
}
*aResults =
static_cast<char16_t**>(nsMemory::Alloc(count * sizeof(**aResults)));
static_cast<char16_t**>(moz_xmalloc(count * sizeof(**aResults)));
*aCount = count;
for (uint32_t i = 0; i < count; i++) {

View File

@ -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);

View File

@ -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);
}

View File

@ -28,7 +28,7 @@ struct nsXBLParameter {
~nsXBLParameter() {
MOZ_COUNT_DTOR(nsXBLParameter);
nsMemory::Free(mName);
free(mName);
NS_CONTENT_DELETE_LIST_MEMBER(nsXBLParameter, this, mNext);
}
};

View File

@ -701,7 +701,7 @@ nsXBLPrototypeBinding::ConstructAttributeTable(nsIContent* aElement)
token = nsCRT::strtok( newStr, ", ", &newStr );
}
nsMemory::Free(str);
free(str);
}
}

View File

@ -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);

View File

@ -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<txXPathNode*>
(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;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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) {

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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;

View File

@ -65,7 +65,7 @@ nsThebesFontEnumerator::EnumerateFonts(const char *aLangGroup,
}
char16_t **fs = static_cast<char16_t **>
(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]);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -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
/**

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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");

View File

@ -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<nsIID**>(nsMemory::Alloc(count * sizeof(nsIID*)));
*aArray = array = static_cast<nsIID**>(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<nsIID**>(nsMemory::Alloc(count * sizeof(nsIID*)));
*aArray = array = static_cast<nsIID**>(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<nsIID**>(nsMemory::Alloc(count * sizeof(nsIID*)));
*aArray = array = static_cast<nsIID**>(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<nsIID**>(nsMemory::Alloc(count * sizeof(nsIID*)));
*aArray = array = static_cast<nsIID**>(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<nsIID**>(nsMemory::Alloc(count * sizeof(nsIID*)));
*aArray = array = static_cast<nsIID**>(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<nsIID**>(nsMemory::Alloc(count * sizeof(nsIID*)));
*aArray = array = static_cast<nsIID**>(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<nsIID**>(nsMemory::Alloc(count * sizeof(nsIID*)));
*aArray = array = static_cast<nsIID**>(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<nsIID**>(nsMemory::Alloc(count * sizeof(nsIID*)));
*aArray = array = static_cast<nsIID**>(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<nsIID**>(nsMemory::Alloc(count * sizeof(nsIID*)));
*aArray = array = static_cast<nsIID**>(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;
}

View File

@ -565,7 +565,7 @@ XPCConvert::JSData2Native(void* d, HandleValue s,
if (length == size_t(-1)) {
return false;
}
char* buffer = static_cast<char*>(nsMemory::Alloc(length + 1));
char* buffer = static_cast<char *>(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<char*>(nsMemory::Alloc(alloc_len));
char* buffer = static_cast<char *>(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;
}

View File

@ -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;
}

View File

@ -87,7 +87,7 @@ BackstagePass::GetInterfaces(uint32_t* aCount, nsIID * **aArray)
const uint32_t count = 2;
*aCount = count;
nsIID** array;
*aArray = array = static_cast<nsIID**>(nsMemory::Alloc(count * sizeof(nsIID*)));
*aArray = array = static_cast<nsIID**>(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;
}

View File

@ -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);

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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;

View File

@ -1264,7 +1264,7 @@ ReadScriptOrFunction(nsIObjectInputStream* stream, JSContext* cx,
}
}
nsMemory::Free(data);
free(data);
return rv;
}

View File

@ -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()

View File

@ -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;

View File

@ -2265,7 +2265,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, csssheet);
shouldOverride = true;
}
nsMemory::Free(str);
free(str);
}
}
}

View File

@ -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;
}

View File

@ -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.

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -3879,7 +3879,7 @@ Selection::GetRangesForInterval(nsIDOMNode* aBeginNode, int32_t aBeginOffset,
}
*aResults = static_cast<nsIDOMRange**>
(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++) {

View File

@ -407,7 +407,7 @@ DestroyUserData(void* aUserData)
{
TextRunUserData* userData = static_cast<TextRunUserData*>(aUserData);
if (userData) {
nsMemory::Free(userData);
free(userData);
}
}
@ -1896,7 +1896,7 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
dummyData.mMappedFlows = &dummyMappedFlow;
} else {
userData = static_cast<TextRunUserData*>
(nsMemory::Alloc(sizeof(TextRunUserData) + mMappedFlows.Length()*sizeof(TextRunMappedFlow)));
(moz_xmalloc(sizeof(TextRunUserData) + mMappedFlows.Length()*sizeof(TextRunMappedFlow)));
userDataToDestroy = userData;
userData->mMappedFlows = reinterpret_cast<TextRunMappedFlow*>(userData + 1);
}
@ -2290,7 +2290,7 @@ BuildTextRunsScanner::SetupLineBreakerContext(gfxTextRun *aTextRun)
dummyData.mMappedFlows = &dummyMappedFlow;
} else {
userData = static_cast<TextRunUserData*>
(nsMemory::Alloc(sizeof(TextRunUserData) + mMappedFlows.Length()*sizeof(TextRunMappedFlow)));
(moz_xmalloc(sizeof(TextRunUserData) + mMappedFlows.Length()*sizeof(TextRunMappedFlow)));
userDataToDestroy = userData;
userData->mMappedFlows = reinterpret_cast<TextRunMappedFlow*>(userData + 1);
}

View File

@ -456,7 +456,7 @@ inDOMUtils::GetCSSPropertyNames(uint32_t aFlags, uint32_t* aCount,
}
char16_t** props =
static_cast<char16_t**>(nsMemory::Alloc(maxCount * sizeof(char16_t*)));
static_cast<char16_t**>(moz_xmalloc(maxCount * sizeof(char16_t*)));
#define DO_PROP(_prop) \
PR_BEGIN_MACRO \
@ -616,7 +616,7 @@ inDOMUtils::GetSubpropertiesForCSSProperty(const nsAString& aProperty,
nsTArray<nsString> array;
if (!nsCSSProps::IsShorthand(propertyID)) {
*aValues = static_cast<char16_t**>(nsMemory::Alloc(sizeof(char16_t*)));
*aValues = static_cast<char16_t**>(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<char16_t**>(nsMemory::Alloc(subpropCount * sizeof(char16_t*)));
static_cast<char16_t**>(moz_xmalloc(subpropCount * sizeof(char16_t*)));
*aLength = subpropCount;
for (const nsCSSProperty *props = nsCSSProps::SubpropertyEntryFor(propertyID),
*props_start = props;

View File

@ -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;
}

View File

@ -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:

View File

@ -1152,7 +1152,7 @@ nsMenuFrame::BuildAcceleratorText(bool aNotify)
token = nsCRT::strtok(newStr, ", \t", &newStr);
}
nsMemory::Free(str);
free(str);
accelText += accelString;

View File

@ -85,7 +85,7 @@ GetInterfaces(std::vector<NetworkInterface>* aInterfaces)
}
}
nsMemory::Free(prefixs);
free(prefixs);
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, ips);
if (!isAddressGot) {

View File

@ -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
}

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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.

View File

@ -331,7 +331,7 @@ protected:
{ /* other members intentionally uninitialized */ }
~HostInfo() {
if (!is_ipaddr && name.host)
nsMemory::Free(name.host);
free(name.host);
}
};

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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 <code>aParamName</code> 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 <code>aParamName</code> after
* RFC 2231 decoding but without charset conversion.
*/

View File

@ -215,7 +215,7 @@ char *combineContinuations(nsTArray<Continuation>& 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<Continuation>& 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;
}

View File

@ -110,7 +110,7 @@ nsAboutCache::NewChannel(nsIURI* aURI,
mBuffer.AppendLiteral("<a href=\"about:cache?storage=&amp;context=");
char* escapedContext = nsEscapeHTML(mContextString.get());
mBuffer.Append(escapedContext);
nsMemory::Free(escapedContext);
free(escapedContext);
mBuffer.AppendLiteral("\">Back to overview</a>");
}
@ -195,13 +195,13 @@ nsAboutCache::FireVisitStorage()
mBuffer.Append(
nsPrintfCString("<p>Unrecognized storage name '%s' in about:cache URL</p>",
escaped));
nsMemory::Free(escaped);
free(escaped);
} else {
char* escaped = nsEscapeHTML(mContextString.get());
mBuffer.Append(
nsPrintfCString("<p>Unrecognized context key '%s' in about:cache URL</p>",
escaped));
nsMemory::Free(escaped);
free(escaped);
}
FlushBuffer();
@ -319,7 +319,7 @@ nsAboutCache::OnCacheStorageInfo(uint32_t aEntryCount, uint64_t aConsumption,
mBuffer.AppendLiteral("&amp;context=");
char* escapedContext = nsEscapeHTML(mContextString.get());
mBuffer.Append(escapedContext);
nsMemory::Free(escapedContext);
free(escapedContext);
mBuffer.AppendLiteral("\">List Cache Entries</a></th>\n"
" </tr>\n");
}
@ -383,12 +383,12 @@ nsAboutCache::OnCacheEntryInfo(nsIURI *aURI, const nsACString & aIdEnhance,
url.AppendLiteral("&amp;context=");
char* escapedContext = nsEscapeHTML(mContextString.get());
url += escapedContext;
nsMemory::Free(escapedContext);
free(escapedContext);
url.AppendLiteral("&amp;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("</a></td>\n");
nsMemory::Free(escapedCacheURI);
free(escapedCacheURI);
// Content length
mBuffer.AppendLiteral(" <td>");

View File

@ -373,7 +373,7 @@ nsAboutCacheEntry::WriteCacheEntryDescription(nsICacheEntry *entry)
} else {
buffer.Append(escapedStr);
}
nsMemory::Free(escapedStr);
free(escapedStr);
buffer.AppendLiteral("</td>\n"
" </tr>\n");
@ -506,7 +506,7 @@ nsAboutCacheEntry::OnMetaDataElement(char const * key, char const * value)
" <td>");
char* escapedValue = nsEscapeHTML(value);
mBuffer->Append(escapedValue);
nsMemory::Free(escapedValue);
free(escapedValue);
mBuffer->AppendLiteral("</td>\n"
" </tr>\n");

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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)

View File

@ -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

View File

@ -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.

View File

@ -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<void*>(ctxt), read, buffer);
}
nsMemory::Free(buffer);
free(buffer);
return NS_OK;
}

View File

@ -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))

View File

@ -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

View File

@ -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;

View File

@ -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;

Some files were not shown because too many files have changed in this diff Show More