CNDP  22.08.0
tb_mem.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2010-2022 Intel Corporation
3  */
4 
5 #ifndef _TB_MEM_H_
6 #define _TB_MEM_H_
7 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #include <cne_acl_osdep.h>
22 #include <setjmp.h> // for sigjmp_buf
23 #include <stddef.h> // for size_t
24 #include <stdint.h> // for uint8_t
25 
26 struct tb_mem_block {
27  struct tb_mem_block *next;
28  struct tb_mem_pool *pool;
29  size_t size;
30  uint8_t *mem;
31 };
32 
33 struct tb_mem_pool {
34  struct tb_mem_block *block;
35  size_t alignment;
36  size_t min_alloc;
37  size_t alloc;
38  /* jump target in case of memory allocation failure. */
39  sigjmp_buf fail;
40 };
41 
42 void *tb_alloc(struct tb_mem_pool *pool, size_t size);
43 void tb_free_pool(struct tb_mem_pool *pool);
44 
45 #ifdef __cplusplus
46 }
47 #endif
48 
49 #endif /* _TB_MEM_H_ */