diff --git a/mozilla/nsprpub/lib/ds/plarena.c b/mozilla/nsprpub/lib/ds/plarena.c index 5b1e53af1f9..cc2ffb00a89 100644 --- a/mozilla/nsprpub/lib/ds/plarena.c +++ b/mozilla/nsprpub/lib/ds/plarena.c @@ -345,6 +345,22 @@ PR_IMPLEMENT(void) PL_ArenaFinish(void) once = pristineCallOnce; } +PR_IMPLEMENT(size_t) PL_SizeOfArenaPoolExcludingPool( + PLArenaPool *pool, PLMallocSizeFn mallocSizeOf) +{ + /* + * The first PLArena is within |pool|, so don't measure it. Subsequent + * PLArenas are separate and must measured. + */ + size_t size = 0; + PLArena *arena = pool->first.next; + while (arena) { + size += mallocSizeOf(arena); + arena = arena->next; + } + return size; +} + #ifdef PL_ARENAMETER PR_IMPLEMENT(void) PL_ArenaCountAllocation(PLArenaPool *pool, PRUint32 nb) { diff --git a/mozilla/nsprpub/lib/ds/plarenas.h b/mozilla/nsprpub/lib/ds/plarenas.h index b4705624318..4cbe32c4c39 100644 --- a/mozilla/nsprpub/lib/ds/plarenas.h +++ b/mozilla/nsprpub/lib/ds/plarenas.h @@ -60,6 +60,19 @@ PR_EXTERN(void) PL_ArenaRelease(PLArenaPool *pool, char *mark); */ PR_EXTERN(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern); +/* +** A function like malloc_size() or malloc_usable_size() that returns the +** size of a heap block. +*/ +typedef size_t (*PLMallocSizeFn)(const void *ptr); + +/* +** Return all memory used by a PLArenaPool, excluding the PLArenaPool +** structure. +*/ +PR_EXTERN(size_t) PL_SizeOfArenaPoolExcludingPool( + PLArenaPool *pool, PLMallocSizeFn mallocSizeOf); + PR_END_EXTERN_C #endif /* PLARENAS_H */ diff --git a/mozilla/nsprpub/lib/ds/plds.def b/mozilla/nsprpub/lib/ds/plds.def index 5c672abb344..cc54a4de2e7 100644 --- a/mozilla/nsprpub/lib/ds/plds.def +++ b/mozilla/nsprpub/lib/ds/plds.def @@ -54,3 +54,7 @@ PL_HashTableRawLookupConst; ;+ global: PL_ClearArenaPool; ;+} NSPR_4.1; +;+NSPR_4.9.6 { +;+ global: +PL_SizeOfArenaPoolExcludingPool; +;+} NSPR_4.8.5;