mirror of
https://github.com/gperftools/gperftools
synced 2025-02-16 11:47:07 +00:00
[osx] unbreak EmergencyMallocNoHook test
OSX's malloc zones stuff is essentially incompatible with emergency malloc. In order to handle it, our unit tests use tc_free directly in order to free memory allocated by emergency malloc. So lets keep doing it for our newer code that exercises calloc/free pair as well.
This commit is contained in:
parent
92fd07cc2f
commit
a4e2f95038
@ -108,6 +108,9 @@ extern "C" {
|
||||
// We need to provide wrappers around all the libc functions.
|
||||
namespace {
|
||||
size_t mz_size(malloc_zone_t* zone, const void* ptr) {
|
||||
// Note, this does not work for emergency malloc's memory. And in
|
||||
// principle OSX doesn't need or use it. But by default we enable
|
||||
// it, so that our unit test coverage is wider.
|
||||
if (MallocExtension::instance()->GetOwnership(ptr) != MallocExtension::kOwned)
|
||||
return 0; // malloc_zone semantics: return 0 if we don't own the memory
|
||||
|
||||
|
@ -1609,7 +1609,7 @@ TEST(TCMallocTest, EmergencyMallocNoHook) {
|
||||
portal->WithEmergencyMallocEnabled([&] () {
|
||||
p2 = noopt(malloc)(32);
|
||||
for (int i = 11; i < 999; i++) {
|
||||
free(p3);
|
||||
tc_free(p3);
|
||||
p3 = tc_calloc(1, i);
|
||||
}
|
||||
p4 = tc_calloc(4096, 1024);
|
||||
|
Loading…
Reference in New Issue
Block a user