Create expression struct and memory pool
This commit is contained in:
15
lib/memory_pool.c
Normal file
15
lib/memory_pool.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "memory_pool.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void init_memory_pool(memory_pool_t *pool)
|
||||
{
|
||||
pool->free_pointer = &pool->buffer[0];
|
||||
}
|
||||
|
||||
expression_t *allocate_expression(memory_pool_t *pool)
|
||||
{
|
||||
if (pool->free_pointer > pool->buffer + MEMORY_POOL_SIZE)
|
||||
return NULL;
|
||||
return pool->free_pointer++;
|
||||
}
|
||||
Reference in New Issue
Block a user