class SerialArena

Defined at line 80 of file ../../third_party/protobuf/src/google/protobuf/serial_arena.h

A simple arena allocator. Calls to allocate functions must be properly

serialized by the caller, hence this class cannot be used as a general

purpose allocator in a multi-threaded program. It serves as a building block

for ThreadSafeArena, which provides a thread-safe arena allocator.

This class manages

1) Arena bump allocation + owning memory blocks.

2) Maintaining a cleanup list.

It delegates the actual memory allocation back to ThreadSafeArena, which

contains the information on block growth policy and backing memory allocation

used.

Public Members

static const size_t kBlockHeaderSize

Public Methods

void CleanupList ()

Defined at line 85 of file ../../third_party/protobuf/src/google/protobuf/serial_arena.h

uint64_t SpaceAllocated ()

Defined at line 86 of file ../../third_party/protobuf/src/google/protobuf/serial_arena.h

uint64_t SpaceUsed ()
void * TryAllocateFromCachedBlock (size_t size)

See comments on `cached_blocks_` member for details.

Defined at line 92 of file ../../third_party/protobuf/src/google/protobuf/serial_arena.h

template <AllocationClient alloc_client = AllocationClient::kDefault>
void * AllocateAligned (size_t n)

In kArray mode we look through cached blocks.

We do not do this by default because most non-array allocations will not

have the right size and will fail to find an appropriate cached block.

TODO: Evaluate if we should use cached blocks for message types of

the right size. We can statically know if the allocation size can benefit

from it.

Defined at line 116 of file ../../third_party/protobuf/src/google/protobuf/serial_arena.h

bool MaybeAllocateAligned (size_t n, void ** out)

Allocate space if the current region provides enough space.

Defined at line 202 of file ../../third_party/protobuf/src/google/protobuf/serial_arena.h

void * MaybeAllocateStringWithCleanup ()

If there is enough space in the current block, allocate space for one

std::string object and register for destruction. The object has not been

constructed and the memory returned is uninitialized.

Defined at line 224 of file ../../third_party/protobuf/src/google/protobuf/serial_arena.h

void * AllocateAlignedWithCleanup (size_t n, size_t align, void (*)(void *) destructor)

Defined at line 229 of file ../../third_party/protobuf/src/google/protobuf/serial_arena.h

void AddCleanup (void * elem, void (*)(void *) destructor)

Defined at line 248 of file ../../third_party/protobuf/src/google/protobuf/serial_arena.h

void * AllocateFromStringBlock ()

Defined at line 424 of file ../../third_party/protobuf/src/google/protobuf/serial_arena.h

std::vector<void *> PeekCleanupListForTesting ()

Friends

class ChunkList
class ThreadSafeArena