Landtiger LPC1768 C BigLib 1
A self made, custom C library for the LandTiger board.
 
Loading...
Searching...
No Matches
allocator.h
Go to the documentation of this file.
1#ifndef __ALLOCATOR_H
2#define __ALLOCATOR_H
3
4#include "types.h"
5
6// TYPES
7
8// Base memory pool structure.
10
11// Specifies the alignment of the memory pool (4 bytes)
12#define _MEM_POOL_ALIGN4(__name, __sz) __attribute__((aligned(4))) u8 __name[__sz] = {0}
13
14// FUNCTIONS
15
21
26void *MEM_Alloc(MEM_Allocator *ma, u32 size);
27
31void MEM_Free(MEM_Allocator *ma, void *ptr);
32
40void *MEM_Realloc(MEM_Allocator *ma, void *ptr, u32 new_size);
41
42#endif
void MEM_Free(MEM_Allocator *ma, void *ptr)
Free a previously allocated block.
Definition allocator.c:98
MEM_Allocator * MEM_Init(void *pool, u32 pool_size)
Creates a new allocator from the given memory pool.
Definition allocator.c:31
void * MEM_Alloc(MEM_Allocator *ma, u32 size)
Allocate a block of memory from the pool with at least 'size' bytes.
Definition allocator.c:52
void * MEM_Realloc(MEM_Allocator *ma, void *ptr, u32 new_size)
Reallocate a previously allocated block to a new size.
Definition allocator.c:131
u32 pool_size
Definition allocator.c:20
void * pool
Definition allocator.c:19
uint32_t u32
Definition types.h:6