MCPcopy Create free account
hub / github.com/beefytech/Beef / Deallocate

Method Deallocate

BeefRT/gperftools/src/thread_cache.h:378–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

376}
377
378inline void ThreadCache::Deallocate(void* ptr, size_t cl) {
379 FreeList* list = &list_[cl];
380 size_ += Static::sizemap()->ByteSizeForClass(cl);
381 ssize_t size_headroom = max_size_ - size_ - 1;
382
383 // This catches back-to-back frees of allocs in the same size
384 // class. A more comprehensive (and expensive) test would be to walk
385 // the entire freelist. But this might be enough to find some bugs.
386 ASSERT(ptr != list->Next());
387
388 list->Push(ptr);
389 ssize_t list_headroom =
390 static_cast<ssize_t>(list->max_length()) - list->length();
391
392 // There are two relatively uncommon things that require further work.
393 // In the common case we're done, and in that case we need a single branch
394 // because of the bitwise-or trick that follows.
395
396 //BCF- we manually scavenge now
397 if ((list_headroom | size_headroom) < 0) {
398 if (list_headroom < 0) {
399 ListTooLong(list, cl);
400 }
401 if (size_ >= max_size_) Scavenge();
402 }
403}
404
405inline ThreadCache* ThreadCache::GetThreadHeap() {
406#ifdef HAVE_TLS

Callers 1

do_free_helperFunction · 0.45

Calls 5

ByteSizeForClassMethod · 0.45
NextMethod · 0.45
PushMethod · 0.45
max_lengthMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected