3 * Copyright 2017 gRPC authors.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 // \file Arena based allocator
20 // Allows very fast allocation of memory, but that memory cannot be freed until
21 // the arena as a whole is freed
22 // Tracks the total memory allocated against it, so that future arenas can
23 // pre-allocate the right amount of memory
24 // This transitional API is deprecated and will be removed soon in favour of
25 // src/core/lib/gprpp/arena.h .
27 #ifndef GRPC_CORE_LIB_GPR_ARENA_H
28 #define GRPC_CORE_LIB_GPR_ARENA_H
30 #include <grpc/support/port_platform.h>
32 #include "src/core/lib/gprpp/arena.h"
34 // TODO(arjunroy) : Remove deprecated gpr_arena API once all callers are gone.
35 typedef class grpc_core::Arena gpr_arena;
36 // Create an arena, with \a initial_size bytes in the first allocated buffer
37 inline gpr_arena* gpr_arena_create(size_t initial_size) {
38 return grpc_core::Arena::Create(initial_size);
40 // Destroy an arena, returning the total number of bytes allocated
41 inline size_t gpr_arena_destroy(gpr_arena* arena) { return arena->Destroy(); }
42 // Allocate \a size bytes from the arena
43 inline void* gpr_arena_alloc(gpr_arena* arena, size_t size) {
44 return arena->Alloc(size);
47 #endif /* GRPC_CORE_LIB_GPR_ARENA_H */