Contiki 2.6
|
The managed memory allocator is a fragmentation-free memory manager. More...
Files | |
file | mmem.c |
Implementation of the managed memory allocator. | |
file | mmem.h |
Header file for the managed memory allocator. | |
Defines | |
#define | MMEM_PTR(m) |
Get a pointer to the managed memory. | |
Functions | |
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. | |
void | mmem_init (void) |
Initialize the managed memory module. |
The managed memory allocator is a fragmentation-free memory manager.
It keeps the allocated memory free from fragmentation by compacting the memory when blocks are freed. A program that uses the managed memory module cannot be sure that allocated memory stays in place. Therefore, a level of indirection is used: access to allocated memory must always be done using a special macro.
#define MMEM_PTR | ( | m | ) |
Get a pointer to the managed memory.
m | A pointer to the struct mmem |
This macro is used to get a pointer to a memory block allocated with mmem_alloc().
Definition at line 76 of file mmem.h.
Referenced by elfloader_arch_allocate_ram().
int mmem_alloc | ( | struct mmem * | m, |
unsigned int | size | ||
) |
Allocate a managed memory block.
m | A pointer to a struct mmem. |
size | The size of the requested memory block |
This function allocates a chunk of managed memory. The memory allocated with this function must be deallocated using the mmem_free() function.
Definition at line 84 of file mmem.c.
References list_add().
Referenced by elfloader_arch_allocate_ram().
void mmem_free | ( | struct mmem * | m | ) |
Deallocate a managed memory block.
m | A pointer to the managed memory block |
This function deallocates a managed memory block that previously has been allocated with mmem_alloc().
Definition at line 120 of file mmem.c.
References list_remove(), and NULL.
Referenced by elfloader_arch_allocate_ram().
void mmem_init | ( | void | ) |
Initialize the managed memory module.
This function initializes the managed memory module and should be called before any other function from the module.
Definition at line 153 of file mmem.c.
References list_init().
Referenced by main().