pelib  2.0.0
include/pelib/malloc.h
Go to the documentation of this file.
00001 #ifndef PELIB_MALLOC_H
00002 #define PELIB_MALLOC_H
00003 
00004 typedef struct mem_block
00005 {
00006         void* space;                    // pointer to space for data in block             
00007         size_t free_size;               // actual free space in block (0 or whole block)  
00008         struct mem_block *next;         // pointer to next block in circular linked list 
00009 } pelib_malloc_block_t;
00010 
00011 typedef struct
00012 {
00013         pelib_malloc_block_t *tail;             // "last" block in linked list of blocks
00014         void* mem;
00015 } pelib_malloc_queue_t;
00016 
00017 void pelib_mem_malloc_init(pelib_malloc_queue_t* spacep, void* mem, size_t size);
00018 void* pelib_mem_malloc(pelib_malloc_queue_t *spacep, size_t size, int alignment);
00019 void pelib_mem_free(pelib_malloc_queue_t *spacep, void *ptr);
00020 
00021 #endif