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

Method allocateZeroFilled

bolt/common/memory/MemoryPool.cpp:613–635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

611 CHECK_AND_INC_MEM_OP_STATS(this, Allocs);
612 const auto size = sizeEach * numEntries;
613 auto alignmentValue = alignment.has_value() ? alignment.value() : alignment_;
614 const auto alignedSize = sizeAlign(size, alignmentValue);
615 reserve(alignedSize);
616 void* buffer = allocator_->allocateZeroFilled(alignedSize);
617 if (FOLLY_UNLIKELY(buffer == nullptr)) {
618 release(alignedSize);
619 handleAllocationFailure(fmt::format(
620 "{} failed with {} entries and {} each from {} {}",
621 __FUNCTION__,
622 numEntries,
623 succinctBytes(sizeEach),
624 toString(),
625 allocator_->getAndClearFailureMessage()));
626 }
627 RECORD_ALLOC(buffer, size);
628 return buffer;
629}
630
631void* MemoryPoolImpl::reallocate(
632 void* p,
633 int64_t size,
634 int64_t newSize,
635 std::optional<uint8_t> alignment) {
636 CHECK_AND_INC_MEM_OP_STATS(this, Allocs);
637 auto alignmentValue = alignment.has_value() ? alignment.value() : alignment_;
638 const auto alignedNewSize = sizeAlign(newSize, alignmentValue);

Callers

nothing calls this directly

Calls 5

succinctBytesFunction · 0.85
has_valueMethod · 0.80
toStringFunction · 0.50
valueMethod · 0.45

Tested by

no test coverage detected