diff --git a/modules/libjar/nsJARFactory.cpp b/modules/libjar/nsJARFactory.cpp index 8189034254c1..6b725426f289 100644 --- a/modules/libjar/nsJARFactory.cpp +++ b/modules/libjar/nsJARFactory.cpp @@ -51,13 +51,10 @@ #include "nsCOMPtr.h" #include "mozilla/ModuleUtils.h" #include "nsIJARFactory.h" -#include "nsRecyclingAllocator.h" #include "nsJARProtocolHandler.h" #include "nsJARURI.h" #include "nsJAR.h" -extern nsRecyclingAllocator *gZlibAllocator; - NS_GENERIC_FACTORY_CONSTRUCTOR(nsJAR) NS_GENERIC_FACTORY_CONSTRUCTOR(nsZipReaderCache) NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsJARProtocolHandler, @@ -87,8 +84,6 @@ static const mozilla::Module::ContractIDEntry kJARContracts[] = { // Jar module shutdown hook static void nsJarShutdown() { - // Release cached buffers from zlib allocator - delete gZlibAllocator; NS_IF_RELEASE(gJarHandler); } diff --git a/modules/libjar/nsZipArchive.cpp b/modules/libjar/nsZipArchive.cpp index 399227d75ce7..2e4ce57c2853 100644 --- a/modules/libjar/nsZipArchive.cpp +++ b/modules/libjar/nsZipArchive.cpp @@ -52,7 +52,6 @@ #define READTYPE PRInt32 #include "zlib.h" #include "nsISupportsUtils.h" -#include "nsRecyclingAllocator.h" #include "prio.h" #include "plstr.h" #include "prlog.h" @@ -66,12 +65,6 @@ #include #endif -/** - * Global allocator used with zlib. Destroyed in module shutdown. - */ -#define NBUCKETS 6 -nsRecyclingAllocator *gZlibAllocator = NULL; - // For placement new used for arena allocations of zip file list #include NEW_H #define ZIP_ARENABLOCKSIZE (1*1024) @@ -118,46 +111,14 @@ static nsresult ResolveSymlink(const char *path); #endif //*********************************************************** -// Allocators for use with zlib -// -// Use a recycling allocator, for re-use of of the zlib buffers. // For every inflation the following allocations are done: -// zlibAlloc(1, 9520) -// zlibAlloc(32768, 1) +// malloc(1 * 9520) +// malloc(32768 * 1) //*********************************************************** -static void * -zlibAlloc(void *opaque, uInt items, uInt size) -{ - nsRecyclingAllocator *zallocator = (nsRecyclingAllocator *)opaque; - if (zallocator) { - return gZlibAllocator->Malloc(items * size); - } - return malloc(items * size); -} - -static void -zlibFree(void *opaque, void *ptr) -{ - nsRecyclingAllocator *zallocator = (nsRecyclingAllocator *)opaque; - if (zallocator) - zallocator->Free(ptr); - else - free(ptr); -} - nsresult gZlibInit(z_stream *zs) { memset(zs, 0, sizeof(z_stream)); - //-- ensure we have our zlib allocator for better performance - if (!gZlibAllocator) { - gZlibAllocator = new nsRecyclingAllocator(NBUCKETS, NS_DEFAULT_RECYCLE_TIMEOUT, "libjar"); - } - if (gZlibAllocator) { - zs->zalloc = zlibAlloc; - zs->zfree = zlibFree; - zs->opaque = gZlibAllocator; - } int zerr = inflateInit2(zs, -MAX_WBITS); if (zerr != Z_OK) return NS_ERROR_OUT_OF_MEMORY;