InfiniTime.git

ref: e5b73212f6addcfdb5e306df63d7135e543c4f8d

src/stdlib.c


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdlib.h>
#include <FreeRTOS.h>

// Override malloc() and free() to use the memory manager from FreeRTOS.
// According to the documentation of libc, we also need to override
// calloc and realloc.
// See https://www.gnu.org/software/libc/manual/html_node/Replacing-malloc.html

void* malloc(size_t size) {
  return pvPortMalloc(size);
}

void free(void* ptr) {
  vPortFree(ptr);
}

void* calloc(size_t num, size_t size) {
  (void)(num);
  (void)(size);
  // Not supported
  return NULL;
}

void *pvPortRealloc(void *ptr, size_t xWantedSize);
void* realloc( void *ptr, size_t newSize) {
  return pvPortRealloc(ptr, newSize);
}