Skip to content

Instantly share code, notes, and snippets.

@awreece
Created June 5, 2012 03:45
Show Gist options
  • Save awreece/2872496 to your computer and use it in GitHub Desktop.
Save awreece/2872496 to your computer and use it in GitHub Desktop.
void ar_free(void* ptr) {
assertf(malloc_initialized, "Free called before initialization");
assert_notnull(ptr);
slab_t* slab = ptr_to_slab(ptr);
assert_notnull(slab);
tcache_t* cache = get_tcache();
// Avoid false sharing by only caching blocks from our arena.
if (slab->bin->arena == cache->arena || !free_to_original) {
tcache_free(cache, slab->bin->slab_class->index, ptr);
} else {
slab_bin_free(slab->bin, slab, ptr);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment