GRPC Core  6.0.0
alloc.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
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
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  */
18 
19 #ifndef GRPC_SUPPORT_ALLOC_H
20 #define GRPC_SUPPORT_ALLOC_H
21 
23 
24 #include <stddef.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 typedef struct gpr_allocation_functions {
31  void* (*malloc_fn)(size_t size);
32  void* (*zalloc_fn)(size_t size);
33  void* (*realloc_fn)(void* ptr, size_t size);
34  void (*free_fn)(void* ptr);
36 
42 GPRAPI void* gpr_malloc(size_t size);
44 GPRAPI void* gpr_zalloc(size_t size);
46 GPRAPI void gpr_free(void* ptr);
48 GPRAPI void* gpr_realloc(void* p, size_t size);
51 GPRAPI void* gpr_malloc_aligned(size_t size, size_t alignment);
53 GPRAPI void gpr_free_aligned(void* ptr);
54 
60 
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 
68 #endif /* GRPC_SUPPORT_ALLOC_H */
struct gpr_allocation_functions gpr_allocation_functions
Definition: alloc.h:30
#define GPRAPI
Definition: port_platform.h:466
GPRAPI void gpr_free_aligned(void *ptr)
free memory allocated by gpr_malloc_aligned
GPRAPI void * gpr_malloc_aligned(size_t size, size_t alignment)
aligned malloc, never returns NULL, will align to alignment, which must be a power of 2...
GPRAPI void gpr_free(void *ptr)
free
void(* free_fn)(void *ptr)
Definition: alloc.h:34
GPRAPI gpr_allocation_functions gpr_get_allocation_functions(void)
Return the family of allocation functions currently in effect.
GPRAPI void * gpr_realloc(void *p, size_t size)
realloc, never returns NULL
GPRAPI void * gpr_zalloc(size_t size)
like malloc, but zero all bytes before returning them
GPRAPI void gpr_set_allocation_functions(gpr_allocation_functions functions)
Request the family of allocation functions in functions be used.
GPRAPI void * gpr_malloc(size_t size)
malloc.