Embedded Artistry libmemory
Memory library for embedded systems (malloc and friends)
|
#include <assert.h>
#include <malloc.h>
#include <stdbool.h>
#include <stdint.h>
#include <threadx/tx_api.h>
Go to the source code of this file.
Functions | |
__attribute__ ((weak)) | |
void | malloc_addblock (void *addr, size_t size) |
Assign blocks of memory for use by malloc(). More... | |
void * | malloc (size_t size) |
void | free (void *ptr) |
Variables | |
static TX_BYTE_POOL | malloc_pool_ |
ThreadX internal memory pool stucture. More... | |
static volatile bool | initialized_ = false |
__attribute__ | ( | (weak) | ) |
Definition at line 25 of file malloc_threadx.c.
void free | ( | void * | ptr | ) |
free should NEVER be called before malloc is init'd
Definition at line 79 of file malloc_threadx.c.
References initialized_.
void* malloc | ( | size_t | size | ) |
In the ThreadX implementaiton, we make sure the ThreadX pool has been created before we try to allocate memory, or there will be an error. We sleep our threads until memory has been added.
Definition at line 53 of file malloc_threadx.c.
References initialized_, and malloc_pool_.
void malloc_addblock | ( | void * | addr, |
size_t | size | ||
) |
Assign blocks of memory for use by malloc().
malloc_addblock must be called before memory allocation calls are made. In this ThreadX implementation, malloc() calls will block until memory has been allocated
Definition at line 36 of file malloc_threadx.c.
References initialized_, and malloc_pool_.
|
static |
Flag that is used in malloc() to cause competing threads to wait until initialization is completed before allocating memory.
Definition at line 21 of file malloc_threadx.c.
Referenced by free(), malloc(), and malloc_addblock().
|
static |
ThreadX internal memory pool stucture.
Definition at line 15 of file malloc_threadx.c.
Referenced by malloc(), and malloc_addblock().