bug 801466 - part 2 remove usage of prmem in gfx/ r=jmuizelaar

This commit is contained in:
Trevor Saunders 2012-12-02 15:33:59 -05:00
parent e69e39bdfb
commit 97fe774225
2 changed files with 12 additions and 15 deletions

View File

@ -5,6 +5,7 @@
#include "nsIMemoryReporter.h"
#include "nsMemory.h"
#include "mozilla/Base64.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/Attributes.h"
@ -41,16 +42,14 @@
#include "imgIEncoder.h"
#include "nsComponentManagerUtils.h"
#include "prmem.h"
#include "nsISupportsUtils.h"
#include "plbase64.h"
#include "nsCOMPtr.h"
#include "nsIConsoleService.h"
#include "nsServiceManagerUtils.h"
#include "nsStringGlue.h"
#include "nsIClipboardHelper.h"
using mozilla::CheckedInt;
using namespace mozilla;
static cairo_user_data_key_t gfxasurface_pointer_key;
@ -776,7 +775,7 @@ gfxASurface::WriteAsPNG_internal(FILE* aFile, bool aBinary)
// got everything. 16 bytes for better padding (maybe)
bufSize += 16;
uint32_t imgSize = 0;
char* imgData = (char*)PR_Malloc(bufSize);
char* imgData = (char*)moz_malloc(bufSize);
if (!imgData)
return;
uint32_t numReadThisTime = 0;
@ -788,9 +787,9 @@ gfxASurface::WriteAsPNG_internal(FILE* aFile, bool aBinary)
if (imgSize == bufSize) {
// need a bigger buffer, just double
bufSize *= 2;
char* newImgData = (char*)PR_Realloc(imgData, bufSize);
char* newImgData = (char*)moz_realloc(imgData, bufSize);
if (!newImgData) {
PR_Free(imgData);
moz_free(imgData);
return;
}
imgData = newImgData;
@ -807,9 +806,10 @@ gfxASurface::WriteAsPNG_internal(FILE* aFile, bool aBinary)
}
// base 64, result will be NULL terminated
char* encodedImg = PL_Base64Encode(imgData, imgSize, nullptr);
PR_Free(imgData);
if (!encodedImg) // not sure why this would fail
nsCString encodedImg;
rv = Base64Encode(Substring(imgData, imgSize), encodedImg);
moz_free(imgData);
if (NS_FAILED(rv)) // not sure why this would fail
return;
nsCString string("data:image/png;base64,");
@ -838,8 +838,6 @@ gfxASurface::WriteAsPNG_internal(FILE* aFile, bool aBinary)
}
}
PR_Free(encodedImg);
return;
}
#endif

View File

@ -11,10 +11,9 @@
#include "zlib.h"
#ifdef WOFF_MOZILLA_CLIENT /* define this when building as part of Gecko */
# include "prmem.h"
# define malloc PR_Malloc
# define realloc PR_Realloc
# define free PR_Free
# define malloc moz_malloc
# define realloc moz_realloc
# define free moz_free
#endif
/*