File ns_malloc.c
File List > neuralSPOT > neuralspot > ns-utils > src > ns_malloc.c
Go to the documentation of this file
#include "ns_malloc.h"
#include "ns_ambiqsuite_harness.h"
// uint8_t ucHeap[NS_MALLOC_HEAP_SIZE_IN_K * 1024];
uint8_t ns_malloc_init() { return 0; };
int total_allocated = 0;
void *ns_malloc(size_t size) {
void *ptr = NULL;
if (size > 0) {
ptr = pvTasklessPortMalloc(size);
} // else NULL if there was an error
total_allocated += size;
// ns_lp_printf("ns_malloc(%d) total %d returning 0x%x\n", size, total_allocated, ptr);
return ptr;
}
void ns_free(void *ptr) {
if (ptr) {
vTasklessPortFree(ptr);
}
// ns_lp_printf("ns_free(0x%x)\n", ptr);
}