|
Embedded SDK
Embedded SDK
|
#include <stdbool.h>#include <stdlib.h>#include <stdint.h>

Go to the source code of this file.
Macros | |
| #define | ALLOC_FILE NULL |
| #define | ALLOC_LINE 0 |
| #define | APP_MEM_ALLOC(size) mem_utils_alloc(size, false, ALLOC_FILE, ALLOC_LINE) |
| #define | APP_MEM_REALLOC(ptr, size) mem_utils_realloc(ptr, size, ALLOC_FILE, ALLOC_LINE) |
| #define | APP_MEM_FREE(ptr) mem_utils_free(ptr, ALLOC_FILE, ALLOC_LINE) |
| #define | APP_MEM_FREE_AND_NULL(ptr) mem_utils_free_and_null(ptr, ALLOC_FILE, ALLOC_LINE) |
| #define | APP_MEM_STRDUP(ptr) mem_utils_strdup(ptr, ALLOC_FILE, ALLOC_LINE) |
| #define | APP_MEM_CALLOC(ptr, size) mem_utils_calloc(ptr, size, false, ALLOC_FILE, ALLOC_LINE) |
| #define | APP_MEM_PERMANENT(ptr, size) mem_utils_calloc(ptr, size, true, ALLOC_FILE, ALLOC_LINE) |
Functions | |
| bool | mem_utils_init (void *heap_start, size_t heap_size) |
| Initializes the App heap buffer. | |
| void * | mem_utils_alloc (size_t size, bool permanent, const char *file, int line) |
| Internal implementation of memory allocation. | |
| void * | mem_utils_realloc (void *ptr, size_t size, const char *file, int line) |
| Internal implementation of memory reallocation. | |
| void | mem_utils_free (void *ptr, const char *file, int line) |
| Internal implementation of memory free. | |
| void | mem_utils_free_and_null (void **buffer, const char *file, int line) |
| Internal implementation of safe free with nullification. | |
| char * | mem_utils_strdup (const char *s, const char *file, int line) |
| Internal implementation of string duplication. | |
| bool | mem_utils_calloc (void **buffer, uint16_t size, bool permanent, const char *file, int line) |
| Internal implementation of memory allocation of a zero-initialized buffer freeing any existing allocation. | |
| #define ALLOC_FILE NULL |
Definition at line 11 of file app_mem_utils.h.
| #define ALLOC_LINE 0 |
Definition at line 12 of file app_mem_utils.h.
| #define APP_MEM_ALLOC | ( | size | ) | mem_utils_alloc(size, false, ALLOC_FILE, ALLOC_LINE) |
Definition at line 16 of file app_mem_utils.h.
| #define APP_MEM_CALLOC | ( | ptr, | |
| size | |||
| ) | mem_utils_calloc(ptr, size, false, ALLOC_FILE, ALLOC_LINE) |
Definition at line 21 of file app_mem_utils.h.
| #define APP_MEM_FREE | ( | ptr | ) | mem_utils_free(ptr, ALLOC_FILE, ALLOC_LINE) |
Definition at line 18 of file app_mem_utils.h.
| #define APP_MEM_FREE_AND_NULL | ( | ptr | ) | mem_utils_free_and_null(ptr, ALLOC_FILE, ALLOC_LINE) |
Definition at line 19 of file app_mem_utils.h.
| #define APP_MEM_PERMANENT | ( | ptr, | |
| size | |||
| ) | mem_utils_calloc(ptr, size, true, ALLOC_FILE, ALLOC_LINE) |
Definition at line 22 of file app_mem_utils.h.
| #define APP_MEM_REALLOC | ( | ptr, | |
| size | |||
| ) | mem_utils_realloc(ptr, size, ALLOC_FILE, ALLOC_LINE) |
Definition at line 17 of file app_mem_utils.h.
| #define APP_MEM_STRDUP | ( | ptr | ) | mem_utils_strdup(ptr, ALLOC_FILE, ALLOC_LINE) |
Definition at line 20 of file app_mem_utils.h.
| void * mem_utils_alloc | ( | size_t | size, |
| bool | permanent, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Internal implementation of memory allocation.
| [in] | size | in bytes to allocate (must be > 0) |
| [in] | permanent | if true, the allocation is never freed (for profiling only) |
| [in] | file | source file requesting the allocation (for profiling only) |
| [in] | line | line in the source file requesting the allocation (for profiling only) |
Definition at line 48 of file app_mem_utils.c.
| bool mem_utils_calloc | ( | void ** | buffer, |
| uint16_t | size, | ||
| bool | permanent, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Internal implementation of memory allocation of a zero-initialized buffer freeing any existing allocation.
| [out] | buffer | pointer to the buffer to allocate |
| [in] | size | (in bytes) to allocate |
| [in] | permanent | if true, the allocation is never freed (for profiling only) |
| [in] | file | source file requesting the allocation (for profiling only) |
| [in] | line | line in the source file requesting the allocation (for profiling only) |
Definition at line 128 of file app_mem_utils.c.
| void mem_utils_free | ( | void * | ptr, |
| const char * | file, | ||
| int | line | ||
| ) |
Internal implementation of memory free.
| [in] | ptr | previously allocated |
| [in] | file | source file requesting the allocation (for profiling only) |
| [in] | line | line in the source file requesting the allocation (for profiling only) |
Definition at line 107 of file app_mem_utils.c.
| void mem_utils_free_and_null | ( | void ** | buffer, |
| const char * | file, | ||
| int | line | ||
| ) |
Internal implementation of safe free with nullification.
| [in,out] | buffer | Pointer to the buffer to deallocate |
| [in] | file | source file requesting the allocation (for profiling only) |
| [in] | line | line in the source file requesting the allocation (for profiling only) |
Definition at line 157 of file app_mem_utils.c.
| bool mem_utils_init | ( | void * | heap_start, |
| size_t | heap_size | ||
| ) |
Initializes the App heap buffer.
| [in] | heap_start | address of the Application heap to use |
| [in] | heap_size | size in bytes of the heap |
Definition at line 30 of file app_mem_utils.c.
| void * mem_utils_realloc | ( | void * | ptr, |
| size_t | size, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Internal implementation of memory reallocation.
| [in] | ptr | previously allocated or NULL (equivalent to alloc) |
| [in] | size | new size in bytes to allocate. Can be 0 (equivalent to free). |
| [in] | file | source file requesting the allocation (for profiling only) |
| [in] | line | line in the source file requesting the allocation (for profiling only) |
Definition at line 76 of file app_mem_utils.c.
| char * mem_utils_strdup | ( | const char * | src, |
| const char * | file, | ||
| int | line | ||
| ) |
Internal implementation of string duplication.
| [in] | src | string to duplicate |
| [in] | file | source file requesting the allocation (for profiling only) |
| [in] | line | line in the source file requesting the allocation (for profiling only) |
Definition at line 173 of file app_mem_utils.c.