A set of memory blocks is statically declared with the MEMB() macro. Memory blocks are allocated from the declared memory by the memb_alloc() function, and are deallocated with the memb_free() function.
Files | |
file | memb.c |
Memory block allocation routines. | |
file | memb.h |
Memory block allocation routines. | |
Data Structures | |
struct | memb_blocks |
Defines | |
#define | MEMB_CONCAT2(s1, s2) s1##s2 |
#define | MEMB_CONCAT(s1, s2) MEMB_CONCAT2(s1, s2) |
#define | MEMB(name, structure, num) |
Declare a memory block. | |
Functions | |
void | memb_init (struct memb_blocks *m) |
Initialize a memory block that was declared with MEMB(). | |
void * | memb_alloc (struct memb_blocks *m) |
Allocate a memory block from a block of memory declared with MEMB(). | |
char | memb_free (struct memb_blocks *m, void *ptr) |
Deallocate a memory block from a memory block previously declared with MEMB(). |
|
Value: static char MEMB_CONCAT(name,_memb_count)[num]; \ static structure MEMB_CONCAT(name,_memb_mem)[num]; \ static struct memb_blocks name = {sizeof(structure), num, \ MEMB_CONCAT(name,_memb_count), \ (void *)MEMB_CONCAT(name,_memb_mem)} This macro is used to staticall declare a block of memory that can be used by the block allocation functions. The macro statically declares a C array with a size that matches the specified number of blocks and their individual sizes. Example: MEMB(connections, sizeof(struct connection), 16);
|
|
Allocate a memory block from a block of memory declared with MEMB().
Definition at line 59 of file memb.c. References memb_blocks::count, memb_blocks::mem, memb_blocks::num, and memb_blocks::size. |
|
Deallocate a memory block from a memory block previously declared with MEMB().
Definition at line 79 of file memb.c. References memb_blocks::count, memb_blocks::mem, and memb_blocks::size. |
|
Initialize a memory block that was declared with MEMB().
Definition at line 52 of file memb.c. References memb_blocks::count, memb_blocks::mem, memb_blocks::num, and memb_blocks::size. |