MCPcopy Create free account
hub / github.com/bytedance/bolt / allocateFromFreeLists

Method allocateFromFreeLists

bolt/common/memory/HashStringAllocator.cpp:393–414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

391}
392
393HashStringAllocator::Header* FOLLY_NULLABLE
394HashStringAllocator::allocateFromFreeLists(
395 int32_t preferredSize,
396 bool mustHaveSize,
397 bool isFinalSize) {
398 if (!numFree_) {
399 return nullptr;
400 }
401 preferredSize = std::max(kMinAlloc, preferredSize);
402 const auto index = freeListIndex(preferredSize);
403 auto available = bits::findFirstBit(freeNonEmpty_, index, kNumFreeLists);
404 if (!mustHaveSize && available == -1) {
405 available = bits::findLastBit(freeNonEmpty_, 0, index);
406 }
407 if (available == -1) {
408 return nullptr;
409 }
410 auto* header =
411 allocateFromFreeList(preferredSize, mustHaveSize, isFinalSize, available);
412 BOLT_CHECK_NOT_NULL(header);
413 return header;
414}
415
416HashStringAllocator::Header* FOLLY_NULLABLE
417HashStringAllocator::allocateFromFreeList(

Callers

nothing calls this directly

Calls 3

findFirstBitFunction · 0.85
findLastBitFunction · 0.85
maxFunction · 0.50

Tested by

no test coverage detected