Allow memory pools to have a fallback.
If it runs out of memory, it will try and allocate from its fallback.
Freed memory is not returned to the fallback until it is finalised.
Change-Id: Ib63ae95321d5d70931dedda3c5f9267caec82b2d
diff --git a/inc/hf/mpool.h b/inc/hf/mpool.h
index 556fea9..0034dbb 100644
--- a/inc/hf/mpool.h
+++ b/inc/hf/mpool.h
@@ -26,11 +26,14 @@
size_t entry_size;
struct mpool_chunk *chunk_list;
struct mpool_entry *entry_list;
+ struct mpool *fallback;
};
void mpool_enable_locks(void);
void mpool_init(struct mpool *p, size_t entry_size);
void mpool_init_from(struct mpool *p, struct mpool *from);
+void mpool_init_with_fallback(struct mpool *p, struct mpool *fallback);
+void mpool_fini(struct mpool *p);
bool mpool_add_chunk(struct mpool *p, void *begin, size_t size);
void *mpool_alloc(struct mpool *p);
void *mpool_alloc_contiguous(struct mpool *p, size_t count, size_t align);