Skip to content
Snippets Groups Projects
Commit 222b2ff6 authored by Marek Vavrusa's avatar Marek Vavrusa
Browse files

Added mempool memory context initializer.

parent 45610510
No related branches found
No related tags found
1 merge request!147Packet Api Rewrite
......@@ -24,6 +24,7 @@
#include "common/mempattern.h"
#include "common/log.h"
#include "common/slab/alloc-common.h"
#include "common/mempool.h"
static void *mm_malloc(void *ctx, size_t n)
{
......@@ -38,6 +39,13 @@ void mm_ctx_init(mm_ctx_t *mm)
mm->free = free;
}
void mm_ctx_mempool(mm_ctx_t *mm, size_t chunk_size)
{
mm->ctx = mp_new(chunk_size);
mm->alloc = (mm_alloc_t)mp_alloc;
mm->free = mm_nofree;
}
void* xmalloc(size_t l)
{
void *p = malloc(l);
......
......@@ -47,6 +47,9 @@ typedef struct mm_ctx {
/*! \brief Initialize default memory allocation context. */
void mm_ctx_init(mm_ctx_t *mm);
/*! \brief Memory pool context. */
void mm_ctx_mempool(mm_ctx_t *mm, size_t chunk_size);
/*! \brief Allocate memory or die. */
void* xmalloc(size_t l);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment