зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 405b97368630 (bug 1074004)
This commit is contained in:
Родитель
ab3a061374
Коммит
6cfdbefa4d
|
@ -5,4 +5,4 @@ Makefile.in build files for the Mozilla build system.
|
|||
|
||||
The nestegg git repository is: git://github.com/kinetiknz/nestegg.git
|
||||
|
||||
The git commit ID used was ec23378e70030bacf3b4905c444c38ef4a37bceb.
|
||||
The git commit ID used was 2f596487949b192fb15866c6f8ecc6b04df92cb8.
|
||||
|
|
|
@ -40,8 +40,10 @@ typedef struct hblock
|
|||
*
|
||||
*/
|
||||
realloc_t halloc_allocator = NULL;
|
||||
realloc_t halloc_wrapped_allocator = NULL;
|
||||
|
||||
#define allocator halloc_allocator
|
||||
#define wrapped_allocator halloc_wrapped_allocator
|
||||
|
||||
/*
|
||||
* static methods
|
||||
|
@ -62,10 +64,7 @@ void * halloc(void * ptr, size_t len)
|
|||
/* set up default allocator */
|
||||
if (! allocator)
|
||||
{
|
||||
if (halloc_set_allocator(realloc) == 0)
|
||||
{
|
||||
halloc_set_allocator(_realloc);
|
||||
}
|
||||
halloc_set_allocator(realloc);
|
||||
assert(allocator);
|
||||
}
|
||||
|
||||
|
@ -190,6 +189,7 @@ int halloc_set_allocator(realloc_t realloc_func)
|
|||
*
|
||||
* Thanks to Stan Tobias for pointing this tricky part out.
|
||||
*/
|
||||
allocator = realloc_func;
|
||||
if (! (p = malloc(1)))
|
||||
/* hmm */
|
||||
return -1;
|
||||
|
@ -197,10 +197,11 @@ int halloc_set_allocator(realloc_t realloc_func)
|
|||
if ((p = realloc_func(p, 0)))
|
||||
{
|
||||
/* realloc_func cannot be used as free() */
|
||||
allocator = _realloc;
|
||||
wrapped_allocator = realloc_func;
|
||||
free(p);
|
||||
return 0;
|
||||
}
|
||||
allocator = realloc_func;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -210,7 +211,7 @@ static void * _realloc(void * ptr, size_t n)
|
|||
* free'ing realloc()
|
||||
*/
|
||||
if (n)
|
||||
return realloc(ptr, n);
|
||||
return wrapped_allocator(ptr, n);
|
||||
free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче