зеркало из https://github.com/mozilla/gecko-dev.git
Bugzilla bug 97485: fixed a few bugs in the zone allocator. Print warning
messages on memory blocks from ordinary malloc. Initialize the zone allocator first during NSPR initialization. Modified files: prmem.c prinit.c
This commit is contained in:
Родитель
79e194da2a
Коммит
18a686e115
|
@ -97,11 +97,12 @@ _PR_DestroyZones(void)
|
|||
while (mz->head) {
|
||||
MemBlockHdr *hdr = mz->head;
|
||||
mz->head = hdr->s.next; /* unlink it */
|
||||
pr_ZoneFree(hdr);
|
||||
free(hdr);
|
||||
mz->elements--;
|
||||
}
|
||||
}
|
||||
}
|
||||
use_zone_allocator = PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -110,7 +111,7 @@ _PR_InitZones(void)
|
|||
int i, j;
|
||||
char *envp;
|
||||
|
||||
if (envp = getenv("NSPR_USE_ZONE_ALLOCATOR")) {
|
||||
if ((envp = getenv("NSPR_USE_ZONE_ALLOCATOR")) != NULL) {
|
||||
use_zone_allocator = (atoi(envp) == 1);
|
||||
}
|
||||
|
||||
|
@ -275,6 +276,9 @@ pr_ZoneRealloc(void *oldptr, PRUint32 bytes)
|
|||
PR_ASSERT(mb->s.magic == ZONE_MAGIC);
|
||||
if (mb->s.magic != ZONE_MAGIC) {
|
||||
/* Maybe this just came from ordinary malloc */
|
||||
fprintf(stderr,
|
||||
"Warning: reallocing memory block %p from ordinary malloc\n",
|
||||
oldptr);
|
||||
/* We don't know how big it is. But we can fix that. */
|
||||
oldptr = realloc(oldptr, bytes);
|
||||
if (!oldptr) {
|
||||
|
@ -329,6 +333,8 @@ pr_ZoneFree(void *ptr)
|
|||
|
||||
if (mb->s.magic != ZONE_MAGIC) {
|
||||
/* maybe this came from ordinary malloc */
|
||||
fprintf(stderr,
|
||||
"Warning: freeing memory block %p from ordinary malloc\n", ptr);
|
||||
free(ptr);
|
||||
return;
|
||||
}
|
||||
|
@ -342,7 +348,7 @@ pr_ZoneFree(void *ptr)
|
|||
if (!mz) {
|
||||
PR_ASSERT(blockSize > 65536);
|
||||
/* This block was not in any zone. Just free it. */
|
||||
free(ptr);
|
||||
free(mb);
|
||||
return;
|
||||
}
|
||||
PR_ASSERT(mz->blockSize == blockSize);
|
||||
|
|
|
@ -169,6 +169,9 @@ static void _PR_InitStuff(void)
|
|||
|
||||
if (_pr_initialized) return;
|
||||
_pr_initialized = PR_TRUE;
|
||||
#ifdef _PR_ZONE_ALLOCATOR
|
||||
_PR_InitZones();
|
||||
#endif
|
||||
#ifdef WINNT
|
||||
_pr_SetNativeThreadsOnlyMode();
|
||||
#endif
|
||||
|
@ -220,10 +223,6 @@ static void _PR_InitStuff(void)
|
|||
_PR_InitCPUs();
|
||||
#endif
|
||||
|
||||
#ifdef _PR_ZONE_ALLOCATOR
|
||||
_PR_InitZones();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XXX: call _PR_InitMem only on those platforms for which nspr implements
|
||||
* malloc, for now.
|
||||
|
|
Загрузка…
Ссылка в новой задаче