diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 255b98fe47..e76e66fabb 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -114,41 +114,33 @@ void arena_delete_object(void* object) { struct ArenaOptions { // This defines the size of the first block requested from the system malloc. // Subsequent block sizes will increase in a geometric series up to a maximum. - size_t start_block_size; + size_t start_block_size = internal::AllocationPolicy::kDefaultStartBlockSize; // This defines the maximum block size requested from system malloc (unless an // individual arena allocation request occurs with a size larger than this // maximum). Requested block sizes increase up to this value, then remain // here. - size_t max_block_size; + size_t max_block_size = internal::GetDefaultArenaMaxBlockSize(); // An initial block of memory for the arena to use, or nullptr for none. If // provided, the block must live at least as long as the arena itself. The // creator of the Arena retains ownership of the block after the Arena is // destroyed. - char* initial_block; + char* initial_block = nullptr; // The size of the initial block, if provided. - size_t initial_block_size; + size_t initial_block_size = 0; // A function pointer to an alloc method that returns memory blocks of size // requested. By default, it contains a ptr to the malloc function. // // NOTE: block_alloc and dealloc functions are expected to behave like // malloc and free, including Asan poisoning. - void* (*block_alloc)(size_t); + void* (*block_alloc)(size_t) = nullptr; // A function pointer to a dealloc method that takes ownership of the blocks // from the arena. By default, it contains a ptr to a wrapper function that // calls free. - void (*block_dealloc)(void*, size_t); - - ArenaOptions() - : start_block_size(internal::AllocationPolicy::kDefaultStartBlockSize), - max_block_size(internal::GetDefaultArenaMaxBlockSize()), - initial_block(nullptr), - initial_block_size(0), - block_alloc(nullptr), - block_dealloc(nullptr) {} + void (*block_dealloc)(void*, size_t) = nullptr; private: internal::AllocationPolicy AllocationPolicy() const {