From 863c5ed327cf886011270beb6954c969d3c97dd0 Mon Sep 17 00:00:00 2001 From: Eric Rahm Date: Wed, 5 Apr 2017 11:16:43 -0700 Subject: [PATCH] Bug 1351801 - Switch libjar over to ArenaAllocator. r=bsmedberg This converts libjar over to using ArenaAllocator instead of plarena.h. All files can now be built in unified mode. MozReview-Commit-ID: Ev8yyhxqRr7 --- modules/libjar/moz.build | 8 ++------ modules/libjar/nsZipArchive.cpp | 14 ++------------ modules/libjar/nsZipArchive.h | 4 ++-- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/modules/libjar/moz.build b/modules/libjar/moz.build index 8fcf043127a0..7860db80c5cd 100644 --- a/modules/libjar/moz.build +++ b/modules/libjar/moz.build @@ -32,16 +32,12 @@ EXPORTS += [ ] UNIFIED_SOURCES += [ - 'nsJARProtocolHandler.cpp', - 'nsJARURI.cpp', -] - -# These files cannot be built in unified mode because they rely on plarena.h. -SOURCES += [ 'nsJAR.cpp', 'nsJARChannel.cpp', 'nsJARFactory.cpp', 'nsJARInputStream.cpp', + 'nsJARProtocolHandler.cpp', + 'nsJARURI.cpp', 'nsZipArchive.cpp', ] diff --git a/modules/libjar/nsZipArchive.cpp b/modules/libjar/nsZipArchive.cpp index f07c42a62aad..7993ebf474c2 100644 --- a/modules/libjar/nsZipArchive.cpp +++ b/modules/libjar/nsZipArchive.cpp @@ -10,11 +10,6 @@ * or pointers to it across thread boundaries. */ -// This must be the first include in the file in order for the -// PL_ARENA_CONST_ALIGN_MASK macro to be effective. -#define PL_ARENA_CONST_ALIGN_MASK (sizeof(void*)-1) -#include "plarena.h" - #define READTYPE int32_t #include "zlib.h" #include "nsISupportsUtils.h" @@ -356,9 +351,6 @@ nsresult nsZipArchive::OpenArchive(nsZipHandle *aZipHandle, PRFileDesc *aFd) { mFd = aZipHandle; - // Initialize our arena - PL_INIT_ARENA_POOL(&mArena, "ZipArena", ZIP_ARENABLOCKSIZE); - //-- get table of contents for archive nsresult rv = BuildFileList(aFd); if (NS_SUCCEEDED(rv)) { @@ -427,7 +419,7 @@ nsresult nsZipArchive::Test(const char *aEntryName) nsresult nsZipArchive::CloseArchive() { if (mFd) { - PL_FinishArenaPool(&mArena); + mArena.Clear(); mFd = nullptr; } @@ -667,9 +659,7 @@ static nsresult ResolveSymlink(const char *path) nsZipItem* nsZipArchive::CreateZipItem() { // Arena allocate the nsZipItem - void *mem; - PL_ARENA_ALLOCATE(mem, &mArena, sizeof(nsZipItem)); - return (nsZipItem*)mem; + return (nsZipItem*)mArena.Allocate(sizeof(nsZipItem)); } //--------------------------------------------- diff --git a/modules/libjar/nsZipArchive.h b/modules/libjar/nsZipArchive.h index 2de67903277f..373492370468 100644 --- a/modules/libjar/nsZipArchive.h +++ b/modules/libjar/nsZipArchive.h @@ -11,12 +11,12 @@ #define ZIP_TABSIZE 256 #define ZIP_BUFLEN (4*1024) /* Used as output buffer when deflating items to a file */ -#include "plarena.h" #include "zlib.h" #include "zipstruct.h" #include "nsAutoPtr.h" #include "nsIFile.h" #include "nsISupportsImpl.h" // For mozilla::ThreadSafeAutoRefCnt +#include "mozilla/ArenaAllocator.h" #include "mozilla/FileUtils.h" #include "mozilla/FileLocation.h" #include "mozilla/UniquePtr.h" @@ -217,7 +217,7 @@ private: NS_DECL_OWNINGTHREAD nsZipItem* mFiles[ZIP_TABSIZE]; - PLArenaPool mArena; + mozilla::ArenaAllocator<1024, sizeof(void*)> mArena; const char* mCommentPtr; uint16_t mCommentLen;