aboutsummaryrefslogtreecommitdiffstats
path: root/vppinfra/vppinfra/mheap.h
diff options
context:
space:
mode:
authorPierre Pfister <ppfister@cisco.com>2016-06-17 13:30:02 +0100
committerDave Barach <openvpp@barachs.net>2016-06-19 13:31:59 +0000
commit889178c02a711fbc66d83415a88608f704fbc561 (patch)
treeb17e56b0d9c803b09a2d75d86c7a24a4e3b7bfc9 /vppinfra/vppinfra/mheap.h
parentf2868fcd2e2cb237854c1ff83b52b656e9027136 (diff)
VPP-152: mheap_alloc returns 0 when the requested heap size is too small
mheap_alloc allocates memory_size bytes of memory and returns a page-aligned memory space prefixed with a word-aligned header of type mheap_t. This header includes the actual usable space size, but when the requested size is too small, the computed size was incorrect (infinite). mheap_alloc now returns 0 in such cases. With help from Yoann Desmouceaux. Change-Id: I00af63d573d6939aca53dbe7ff612b726bd8f0df Signed-off-by: Pierre Pfister <ppfister@cisco.com>
Diffstat (limited to 'vppinfra/vppinfra/mheap.h')
-rw-r--r--vppinfra/vppinfra/mheap.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/vppinfra/vppinfra/mheap.h b/vppinfra/vppinfra/mheap.h
index c9eb60de639..a40c26cb60d 100644
--- a/vppinfra/vppinfra/mheap.h
+++ b/vppinfra/vppinfra/mheap.h
@@ -48,7 +48,11 @@
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. */
+/* 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);