X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=vppinfra%2Fvppinfra%2Fmheap.h;h=5b7cdfbaf8df29a09b7dd4b463b80feffdfd082a;hb=d5fcc468f33189c64c638c146812c534bcecac61;hp=c9eb60de639f2f1a1a627672abde789dadd4a377;hpb=cb9cadad578297ffd78fa8a33670bdf1ab669e7e;p=vpp.git diff --git a/vppinfra/vppinfra/mheap.h b/vppinfra/vppinfra/mheap.h index c9eb60de639..5b7cdfbaf8d 100644 --- a/vppinfra/vppinfra/mheap.h +++ b/vppinfra/vppinfra/mheap.h @@ -39,41 +39,56 @@ #define included_mheap_h #include -#include /* clib_error_t */ -#include /* clib_mem_usage_t */ +#include /* clib_error_t */ +#include /* clib_mem_usage_t */ #include /* for unformat_input_t */ /* Allocate size bytes. New heap and offset are returned. offset == ~0 means allocation failed. */ -always_inline void * mheap_get (void * v, uword size, uword * offset_return) -{ return mheap_get_aligned (v, size, 0, 0, offset_return); } - -/* Create allocation heap of given size. */ -void * mheap_alloc (void * memory, uword memory_bytes); -void * mheap_alloc_with_flags (void * memory, uword memory_bytes, uword flags); +always_inline void * +mheap_get (void *v, uword size, uword * offset_return) +{ + return mheap_get_aligned (v, size, 0, 0, offset_return); +} + +/* Create allocation heap of given size. + * The actual usable size is smaller than the requested size. + * memory_bytes must be greater than mheap_page_size + sizeof (mheap_t) + 16. + * Otherwise, allocation may fail and return 0. + */ +void *mheap_alloc (void *memory, uword memory_bytes); +void *mheap_alloc_with_flags (void *memory, uword memory_bytes, uword flags); #define mheap_free(v) (v) = _mheap_free(v) -void * _mheap_free (void * v); +void *_mheap_free (void *v); -void mheap_foreach (void * v, - uword (* func) (void * arg, void * v, void * elt_data, uword elt_size), - void * arg); +void mheap_foreach (void *v, + uword (*func) (void *arg, void *v, void *elt_data, + uword elt_size), void *arg); /* Format mheap data structures as string. */ -u8 * format_mheap (u8 * s, va_list * va); +u8 *format_mheap (u8 * s, va_list * va); /* Validate internal consistency. */ -void mheap_validate (void * h); +void mheap_validate (void *h); /* Query bytes used. */ -uword mheap_bytes (void * v); +uword mheap_bytes (void *v); -void mheap_usage (void * v, clib_mem_usage_t * usage); +void mheap_usage (void *v, clib_mem_usage_t * usage); /* Enable disable traceing. */ -void mheap_trace (void * v, int enable); +void mheap_trace (void *v, int enable); /* Test routine. */ int test_mheap_main (unformat_input_t * input); #endif /* included_mheap_h */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */