Contiki 2.5
|
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 | |
Macros | |
#define | MMEM_PTR(m) |
Get a pointer to the managed memory. More... | |
Functions | |
int | mmem_alloc (struct mmem *m, unsigned int size) |
Allocate a managed memory block. More... | |
void | mmem_free (struct mmem *m) |
Deallocate a managed memory block. More... | |
int | mmem_realloc (struct mmem *mem, unsigned int size) |
Change the size of allocated memory. More... | |
void | mmem_reparent (struct mmem *m_old, struct mmem *m_new) |
Assign a chunk of memory form one mem struct to another. More... | |
void | mmem_init (void) |
Initialize the managed memory module. More... | |
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 |
Definition at line 76 of file mmem.h.
Referenced by bundle_add_block(), bundle_create_bundle(), bundle_decrement(), bundle_delete_bundle(), bundle_encode_bundle(), bundle_get_attr(), bundle_get_block(), bundle_get_block_by_type(), bundle_increment(), bundle_recover_bundle(), bundle_set_attr(), delivery_deliver_bundle(), delivery_unblock_service(), dispatching_check_report(), dispatching_dispatch_bundle(), elfloader_arch_allocate_ram(), routing_epidemic_bundle_delivered_locally(), routing_epidemic_new_bundle(), routing_flooding_bundle_delivered_locally(), routing_flooding_bundle_sent(), routing_flooding_check_keep_bundle(), routing_flooding_delete_bundle(), routing_flooding_new_bundle(), routing_flooding_send_to_known_neighbours(), statusreport_basic_send(), storage_coffee_delete_bundle(), storage_coffee_make_room(), storage_coffee_read_bundle(), storage_coffee_reconstruct_bundles(), storage_coffee_save_bundle(), storage_mmem_delete_bundle(), storage_mmem_make_room(), storage_mmem_prune(), storage_mmem_read_bundle(), storage_mmem_reinit(), and storage_mmem_save_bundle().
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 |
Definition at line 99 of file mmem.c.
References list_add().
Referenced by bundle_create_bundle(), elfloader_arch_allocate_ram(), and routing_flooding_new_bundle().
void mmem_free | ( | struct mmem * | m | ) |
Deallocate a managed memory block.
m | A pointer to the managed memory block |
Definition at line 144 of file mmem.c.
References list_remove(), and NULL.
Referenced by elfloader_arch_allocate_ram(), routing_flooding_delete_bundle(), and routing_flooding_new_bundle().
void mmem_init | ( | void | ) |
Initialize the managed memory module.
Definition at line 255 of file mmem.c.
References list_init().
Referenced by main(), and storage_mmem_init().
int mmem_realloc | ( | struct mmem * | mem, |
unsigned int | size | ||
) |
Change the size of allocated memory.
mem | mmem chunk whose size should be changed |
size | Size to change the chunk to |
Definition at line 183 of file mmem.c.
References NULL.
Referenced by bundle_add_block(), and storage_coffee_read_bundle().
void mmem_reparent | ( | struct mmem * | m_old, |
struct mmem * | m_new | ||
) |
Assign a chunk of memory form one mem struct to another.
m_old | Old mmem struct that contains the memory |
m_new | New mmem struct that will contain the memory after this call |
Definition at line 235 of file mmem.c.
References list_insert(), and list_remove().