class Arena
Defined at line 226 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
Public Members
static const size_t kBlockOverhead
Public Methods
void Arena ()
Default constructor with sensible default options, tuned for average
use-cases.
Defined at line 293 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
void Arena (char * initial_block, size_t initial_block_size)
Construct an arena with default options, except for the supplied
initial block. It is more efficient to use this constructor
instead of passing ArenaOptions if the only configuration needed
by the caller is supplying an initial block.
Defined at line 299 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
void Arena (const ArenaOptions & options)
Arena constructor taking custom options. See ArenaOptions above for
descriptions of the options available.
Defined at line 304 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
void ~Arena ()
Defined at line 318 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
template <typename T, typename... Args>
T * Create (Arena * arena, Args &&... args)
Allocates an object type T if the arena passed in is not nullptr;
otherwise, returns a heap-allocated object.
In new code, prefer `arena.Make
<T
>()` when it is statically known to have
an arena, and `Arena::MakeUnique
<T
>(arena)` when you have a potentially
null Arena*. These functions return smart pointers that help manage the
lifetime of the returned object.
Defined at line 328 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
template <typename T,int&,typename... Args>
UniquePtr<T> MakeUnique (Arena * arena, Args &&... args)
Allocates an object type T if the arena passed in is not nullptr;
otherwise, returns a heap-allocated object.
The returned smart pointer owns the object even in the arena case.
Defined at line 362 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
template <typename T,int&,typename... Args>
Ptr<T> Make (Args &&... args)
Allocates an object type T in the arena.
As opposed to `MakeUnique`, this is a non-static member implying that there
is always an `Arena` instance.
The returned value is always Arena owned.
Note that `arena->Make
<T
>()` has undefined behavior if `arena` is null. If
the caller is uncertain of the nullness of the arena pointer, it should
prefer `MakeUnique
<T
>(arena)` instead.
Defined at line 378 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
template <typename T>
UniquePtr<T> UnsafeWrapUniquePtr (Arena * owning_arena, T * ptr)
Creates a `UniquePtr` with an explicit owning arena.
If `owning_arena` is not the actual owner of `ptr`, the behavior is
undefined. As such, this function is unsafe and should be of last resort.
Note: The owning arena is not necessarily the same as `msg->GetArena()`.
Do not use `msg->GetArena()` as the owning arena.
Defined at line 390 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
template <typename T>
void Destroy (T * obj)
API to delete any objects not on an arena. This can be used to safely
clean up messages or repeated fields without knowing whether or not they're
owned by an arena. The pointer passed to this function should not be used
again.
Defined at line 400 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
void * AllocateAligned (size_t size, size_t align)
Allocates memory with the specific size and alignment.
Defined at line 405 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
template <typename T>
T * CreateArray (Arena * arena, size_t num_elements)
Create an array of object type T on the arena *without* invoking the
constructor of T. If `arena` is null, then the return value should be freed
with `delete[] x;` (or `::operator delete[](x);`).
To ensure safe uses, this function checks at compile time
(when compiled as C++11) that T is trivially default-constructible and
trivially destructible.
Defined at line 427 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
uint64_t SpaceAllocated ()
The following routines are for monitoring. They will approximate the total
sum allocated and used memory, but the exact value is an implementation
deal. For instance allocated space depends on growth policies. Do not use
these in unit tests. Returns the total space allocated by the arena, which
is the sum of the sizes of the underlying blocks.
Defined at line 453 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
uint64_t SpaceUsed ()
Returns the total space used by the arena. Similar to SpaceAllocated but
does not include free space and block overhead. This is a best-effort
estimate and may inaccurately calculate space used by other threads
executing concurrently with the call to this method. These inaccuracies
are due to race conditions, and are bounded but unpredictable. Stale data
can lead to underestimates of the space used, and race conditions can lead
to overestimates (up to the current block size).
Defined at line 463 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
uint64_t Reset ()
Frees all storage allocated by this arena after calling destructors
registered with OwnDestructor() and freeing objects registered with Own().
Any objects allocated on this arena are unusable after this call. It also
returns the total space used by the arena which is the sums of the sizes
of the allocated blocks. This method is not thread-safe.
Defined at line 472 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
template <typename T>
void Own (T * object)
Adds |object| to a list of heap-allocated objects to be freed with |delete|
when the arena is destroyed or reset.
Defined at line 477 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
template <typename T>
void OwnDestructor (T * object)
Adds |object| to a list of objects whose destructors will be manually
called when the arena is destroyed or reset. This differs from Own() in
that it does not free the underlying memory with |delete|; hence, it is
normally only used for objects that are placement-newed into
arena-allocated memory.
Defined at line 495 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
void OwnCustomDestructor (void * object, void (*)(void *) destruct)
Adds a custom member function on an object to the list of destructors that
will be manually called when the arena is destroyed or reset. This differs
from OwnDestructor() in that any member function may be specified, not only
the class destructor.
Defined at line 505 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
template <typename T>
Arena * InternalGetArena (T * p)
Provides access to protected GetArena to generated messages.
For internal use only.
Defined at line 641 of file ../../third_party/protobuf/src/src/google/protobuf/arena.h
Records
Friends
class ArenaTestPeer
internal::SerialArena * Arena (Arena * )
class ExtensionSet
class UntypedMapBase
class RepeatedPtrFieldBase
template <typename>
class RepeatedField
template <typename Key, typename T>
class Map
class MessageLite
class TcParser
class EpsCopyInputStream
class LazyField
class InternalMetadata
template <typename Type>
class GenericTypeHandler