FreeRTOS_new.cpp
Go to the documentation of this file.
1 
11 #include <new>
12 #include <cstdlib>
13 #include <compiler.h>
14 
15 extern "C" void * pvPortMalloc(size_t xWantedSize);
16 extern "C" void vPortFree(void * pv);
17 
18 void * operator new(size_t size)
19 {
20  void* ptr = pvPortMalloc(size);
21  while (ptr == 0) {}
22  return ptr;
23 }
24 
25 void operator delete(void *p)
26 {
27  vPortFree(p);
28 }
29 
30 void * operator new[](size_t size)
31 {
32  void* ptr = pvPortMalloc(size);
33  while (ptr == 0) {}
34  return ptr;
35 }
36 
37 void operator delete[](void *p)
38 {
39  vPortFree(p);
40 }
41 
42 
43 // These override the standard libc-nano malloc & free
44 // #pragma GCC push_options
45 // #pragma GCC optimize ("O0")
46 
47 void *malloc( size_t size )
48 {
49  return pvPortMalloc( size );
50 }
51 
52 void free( void *ptr )
53 {
54  vPortFree( ptr );
55 }
56 
57 void *realloc(void *ptr, size_t size)
58 { // Not available
59  return nullptr;
60 }
61 
62 void *calloc(size_t nitems, size_t size)
63 { // Not available
64  return nullptr;
65 }
66 
67 // #pragma GCC pop_options
68 
void * pvPortMalloc(size_t xWantedSize)
Definition: heap_4.c:155
void vPortFree(void *pv)
Definition: heap_4.c:311
Commonly used includes, types and macros.
void free(void *ptr)
void * realloc(void *ptr, size_t size)
void * malloc(size_t size)
void * calloc(size_t nitems, size_t size)


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:57