mbed-os for GR-LYCHEE

Dependents:   mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more

Embed: (wiki syntax)

« Back to documentation index

mem.h File Reference

mem.h File Reference

Heap API. More...

Go to the source code of this file.

Functions

void mem_init (void)
 mem_init is not used when using pools instead of a heap or using C library malloc().
void * mem_trim (void *mem, mem_size_t size)
 mem_trim is not used when using pools instead of a heap or using C library malloc(): we can't free part of a pool element and the stack support mem_trim() to return a different pointer
void * mem_malloc (mem_size_t size)
 Allocate a block of memory with a minimum of 'size' bytes.
void * mem_calloc (mem_size_t count, mem_size_t size)
 Contiguously allocates enough space for count objects that are size bytes of memory each and returns a pointer to the allocated memory.
void mem_free (void *mem)
 Put memory back on the heap.

Detailed Description

Heap API.

Definition in file mem.h.


Function Documentation

void* mem_calloc ( mem_size_t  count,
mem_size_t  size 
)

Contiguously allocates enough space for count objects that are size bytes of memory each and returns a pointer to the allocated memory.

The allocated memory is filled with bytes of value zero.

Parameters:
countnumber of objects to allocate
sizesize of the objects to allocate
Returns:
pointer to allocated memory / NULL pointer if there is an error

Definition at line 748 of file lwip_mem.c.

void mem_free ( void *  rmem )

Put memory back on the heap.

Put a struct mem back on the heap.

Free memory previously allocated by mem_malloc.

Parameters:
rmemis the pointer as returned by a previous call to mem_malloc()

Loads the pool number and calls memp_free with that pool number to put the element back into its pool

Parameters:
rmemthe memory element to free
rmemis the data portion of a struct mem as returned by a previous call to mem_malloc()

Definition at line 143 of file lwip_mem.c.

void mem_init ( void   )

mem_init is not used when using pools instead of a heap or using C library malloc().

Zero the heap and initialize start, end and lowest-free.

Definition at line 75 of file lwip_mem.c.

void* mem_malloc ( mem_size_t  size )

Allocate a block of memory with a minimum of 'size' bytes.

Allocate memory: determine the smallest pool that is big enough to contain an element of 'size' and get an element from that pool.

Parameters:
sizeis the minimum size of the requested block in bytes.
Returns:
pointer to allocated memory or NULL if no free memory was found.

Note that the returned value must always be aligned (as defined by MEM_ALIGNMENT).

Parameters:
sizethe size in bytes of the memory needed
Returns:
a pointer to the allocated memory or NULL if the pool is empty
Parameters:
sizeis the minimum size of the requested block in bytes.
Returns:
pointer to allocated memory or NULL if no free memory was found.

Note that the returned value will always be aligned (as defined by MEM_ALIGNMENT).

Try a bigger pool if this one is empty!

Definition at line 122 of file lwip_mem.c.

void* mem_trim ( void *  mem,
mem_size_t  size 
)

mem_trim is not used when using pools instead of a heap or using C library malloc(): we can't free part of a pool element and the stack support mem_trim() to return a different pointer

Shrink memory returned by mem_malloc().

Parameters:
rmempointer to memory allocated by mem_malloc the is to be shrinked
newsizerequired size after shrinking (needs to be smaller than or equal to the previous size)
Returns:
for compatibility reasons: is always == rmem, at the moment or NULL if newsize is > old size, in which case rmem is NOT touched or freed!

Definition at line 84 of file lwip_mem.c.