Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
os/stack_malloc.c
Go to the documentation of this file.
1
33#include <stdlib.h>
34
35#include "openmrn_features.h"
36
37#if OPENMRN_FEATURE_THREAD_FREERTOS
38const void *__attribute__((weak)) stack_malloc(unsigned long length);
39
40const void *stack_malloc(unsigned long length)
41{
42 /* We do a trick here to ensure that the compiler will output a stack frame
43 * for this function. We want to avoid tail-chain optimization in this
44 * function or else it disappears from the stack traces done for memory
45 * tracing. */
46 void *volatile v = malloc(length);
47 return v;
48}
49#endif
50
51void *buffer_malloc(size_t length) __attribute__((weak));
52
53void *buffer_malloc(size_t length)
54{
55 /* We do a trick here to ensure that the compiler will output a stack frame
56 * for this function. We want to avoid tail-chain optimization in this
57 * function or else it disappears from the stack traces done for memory
58 * tracing. */
59 void *volatile v = malloc(length);
60 return v;
61}
void * stack_malloc(unsigned long length)
Custom malloc function for stack spaces.
void * buffer_malloc(size_t length)
malloc implementation used for allocating buffer space.