MCPcopy Create free account
hub / github.com/bytedance/sonic-cpp / AddChunk

Method AddChunk

include/sonic/allocator.h:437–450  ·  view source on GitHub ↗

Creates a new chunk. ! \param capacity Capacity of the chunk in bytes. \return true if success. */

Source from the content-addressed store, hash-verified

435 \return true if success.
436 */
437 bool AddChunk(size_t capacity) {
438 if (!baseAllocator_) {
439 shared_->ownBaseAllocator = baseAllocator_ = new BaseAllocator();
440 }
441 if (ChunkHeader* chunk = static_cast<ChunkHeader*>(
442 baseAllocator_->Malloc(SIZEOF_CHUNK_HEADER + capacity))) {
443 chunk->capacity = capacity;
444 chunk->size = 0;
445 chunk->next = shared_->chunkHead;
446 shared_->chunkHead = chunk;
447 return true;
448 }
449 return false;
450 }
451
452 static inline void* AlignBuffer(void* buf, size_t& size) {
453 sonic_assert(buf != 0);

Callers

nothing calls this directly

Calls 1

MallocMethod · 0.45

Tested by

no test coverage detected