38 #ifndef _included_clib_mem_h 39 #define _included_clib_mem_h 49 #define CLIB_MAX_MHEAPS 256 73 int os_out_of_memory_on_failure)
78 if (align_offset > align)
81 align_offset %= align;
101 if (os_out_of_memory_on_failure)
143 #define clib_mem_alloc_aligned_no_fail(size,align) \ 145 uword _clib_mem_alloc_size = (size); \ 146 void * _clib_mem_alloc_p; \ 147 _clib_mem_alloc_p = clib_mem_alloc_aligned (_clib_mem_alloc_size, (align)); \ 148 if (! _clib_mem_alloc_p) \ 149 clib_panic ("failed to allocate %d bytes", _clib_mem_alloc_size); \ 153 #define clib_mem_alloc_no_fail(size) clib_mem_alloc_aligned_no_fail(size,1) 156 #define clib_mem_alloc_stack(bytes) __builtin_alloca(bytes) 198 if (old_size < new_size)
199 copy_size = old_size;
201 copy_size = new_size;
269 #ifdef CLIB_LINUX_KERNEL 277 #ifdef CLIB_STANDALONE
void clib_mem_validate(void)
void * clib_per_cpu_mheaps[CLIB_MAX_MHEAPS]
static void * clib_mem_alloc_aligned_at_offset(uword size, uword align, uword align_offset, int os_out_of_memory_on_failure)
uword bytes_free_reclaimed
static void * clib_mem_realloc(void *p, uword new_size, uword old_size)
void os_out_of_memory(void)
static uword mheap_elt_data_bytes(mheap_elt_t *e)
static void * clib_mem_get_per_cpu_heap(void)
u8 * format_clib_mem_usage(u8 *s, va_list *args)
void * clib_mem_init(void *heap, uword size)
#define VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed)
static void * clib_mem_alloc_or_null(uword size)
void * mheap_get_aligned(void *v, uword n_user_data_bytes, uword align, uword align_offset, uword *offset_return)
static void * clib_mem_set_heap(void *heap)
#define clib_memcpy(a, b, c)
static uword clib_mem_size(void *p)
static void * clib_mem_get_heap(void)
static void * clib_mem_alloc_aligned_or_null(uword size, uword align)
static void clib_mem_free(void *p)
static uword clib_mem_is_heap_object(void *p)
static void * clib_mem_alloc(uword size)
static void * clib_mem_set_per_cpu_heap(u8 *new_heap)
static mheap_elt_t * mheap_elt_at_uoffset(void *v, uword uo)
template key/value backing page structure
void mheap_put(void *v, uword uoffset)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void clib_mem_usage(clib_mem_usage_t *usage)
static_always_inline uword os_get_thread_index(void)
static mheap_elt_t * mheap_next_elt(mheap_elt_t *e)
struct clib_bihash_value offset
template key/value backing page structure
static void * clib_mem_alloc_aligned(uword size, uword align)
#define VALGRIND_FREELIKE_BLOCK(addr, rzB)
static uword mheap_data_bytes(void *v, uword uo)
void clib_mem_trace(int enable)
uword clib_mem_get_page_size(void)
static mheap_elt_t * mheap_user_pointer_to_elt(void *v)