issue-470: Allows the default system allocator to be overidden

This is useful when you run into cases where you need an allocator
before tcmalloc has been fully initialized.


git-svn-id: http://gperftools.googlecode.com/svn/trunk@186 6b5cf1ce-ec42-a296-1ba9-69fdba395a50
This commit is contained in:
chappedm@gmail.com 2012-12-22 18:53:18 +00:00
parent 3bf5f55d78
commit 990889e623
1 changed files with 8 additions and 1 deletions

View File

@ -449,6 +449,12 @@ void* DefaultSysAllocator::Alloc(size_t size, size_t *actual_size,
return NULL;
}
ATTRIBUTE_WEAK ATTRIBUTE_NOINLINE
SysAllocator *tc_get_sysalloc_override(SysAllocator *def)
{
return def;
}
static bool system_alloc_inited = false;
void InitSystemAllocators(void) {
MmapSysAllocator *mmap = new (mmap_space) MmapSysAllocator();
@ -469,7 +475,8 @@ void InitSystemAllocators(void) {
sdef->SetChildAllocator(sbrk, 0, sbrk_name);
sdef->SetChildAllocator(mmap, 1, mmap_name);
}
sys_alloc = sdef;
sys_alloc = tc_get_sysalloc_override(sdef);
}
void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size,