Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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:
-
count number of objects to allocate size size 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:
-
rmem is 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:
-
rmem the memory element to free rmem is 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:
-
size is 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:
-
size the size in bytes of the memory needed
- Returns:
- a pointer to the allocated memory or NULL if the pool is empty
- Parameters:
-
size is 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:
-
rmem pointer to memory allocated by mem_malloc the is to be shrinked newsize required 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.
Generated on Tue Jul 12 2022 15:17:52 by
