49 #include "contiki-conf.h"
53 #define MMEM_SIZE MMEM_CONF_SIZE
55 #define MMEM_SIZE 4096
59 unsigned int avail_memory;
60 static char memory[MMEM_SIZE];
86 if(avail_memory < size) {
96 m->ptr = &memory[MMEM_SIZE - avail_memory];
102 avail_memory -= size;
123 if(m->next !=
NULL) {
126 memmove(m->ptr, m->next->ptr,
127 &memory[MMEM_SIZE - avail_memory] - (
char *)m->next->ptr);
131 for(n = m->next; n !=
NULL; n = n->next) {
132 n->ptr = (
void *)((
char *)n->ptr - m->size);
136 avail_memory += m->size;
155 avail_memory = MMEM_SIZE;
Linked list manipulation routines.
Header file for the managed memory allocator
void mmem_init(void)
Initialize the managed memory module.
#define NULL
The null pointer.
void list_remove(list_t list, void *item)
Remove a specific element from a list.
void list_init(list_t list)
Initialize a list.
void list_add(list_t list, void *item)
Add an item at the end of a list.
#define LIST(name)
Declare a linked list.
int mmem_alloc(struct mmem *m, unsigned int size)
Allocate a managed memory block.
void mmem_free(struct mmem *m)
Deallocate a managed memory block.