|
Embedded Artistry Framework
Embedded Systems C++ Framework
|
#include <assert.h>#include <malloc.h>#include <stdbool.h>#include <stdint.h>#include <threadx/tx_api.h>
Functions | |
| __attribute__ ((weak)) | |
| void | malloc_addblock (void *addr, size_t size) |
| malloc_addblock must be called before memory allocation calls are made. More... | |
| void * | malloc (size_t size) |
| Allocates size bytes of uninitialized storage. More... | |
| void | free (void *ptr) |
| Deallocates allocated memory space. More... | |
Variables | |
| static TX_BYTE_POOL | malloc_pool_ |
| ThreadX internal memory pool stucture. More... | |
| static volatile bool | initialized_ = false |
| Flag that is used in malloc() to cause competing threads to wait until initialization is completed before allocating memory. More... | |
| __attribute__ | ( | (weak) | ) |
| void free | ( | void * | ptr | ) |
Deallocates allocated memory space.
Deallocates the space previously allocated by
The behavior is undefined if the value of ptr does not equal a value returned earlier by
The behavior is undefined if the memory area referred to by ptr has already been deallocated, that is, free() or realloc has already been called with ptr as the argument and no calls to malloc, calloc or realloc resulted in a pointer equal to ptr afterwards.
The behavior is undefined if after free returns, an access is made through the pointer ptr (unless another allocation function happened to result in a pointer value equal to ptr)
| ptr | pointer to the memory to deallocate |
free should NEVER be called before malloc is init'd
References assert, initialized_, r, tx_byte_release(), and TX_SUCCESS.
Referenced by _readMemory(), aligned_free(), calloc_test(), char_test(), embvm::VirtualHeap< THeapImpl >::free(), heapsort(), heapsort_r(), realloc(), reallocf(), strdup_test(), strndup_test(), and t_choose().

| void* malloc | ( | size_t | size | ) |
Allocates size bytes of uninitialized storage.
If size is zero, the behavior is implementation defined (null pointer may be returned, or some non-null pointer may be returned that may not be used to access storage, but has to be passed to
| size | number of bytes to allocate |
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.
References assert, initialized_, malloc_pool_, NULL, r, tx_byte_allocate(), TX_SUCCESS, tx_thread_sleep(), and TX_WAIT_FOREVER.
Referenced by _readMemory(), aligned_malloc(), calloc(), char_test(), heapsort(), heapsort_r(), realloc(), strdup(), strndup(), t_choose(), and vasprintf().

| void malloc_addblock | ( | void * | addr, |
| size_t | size | ||
| ) |
malloc_addblock must be called before memory allocation calls are made.
Assign blocks of memory for use by malloc().
In this ThreadX implementation, malloc() calls will block until memory has been allocated
References assert, initialized_, malloc_pool_, r, tx_byte_pool_create, and TX_SUCCESS.
Referenced by allocate_memory(), NRF52DongleHWPlatform::earlyInitHook_(), and nRF52DK_FrameworkDemoPlatform::earlyInitHook_().

Flag that is used in malloc() to cause competing threads to wait until initialization is completed before allocating memory.
Referenced by free(), malloc(), and malloc_addblock().
|
static |
ThreadX internal memory pool stucture.
Referenced by malloc(), and malloc_addblock().
1.8.15