extern
porcupine
demo
mcu
stm32h747
stm32h747i-disco
CM7
Src
stm32h747/stm32h747i-disco/CM7/Src/sysmem.c
Go to the documentation of this file.
1
24
/* Includes */
25
#include <errno.h>
26
#include <stdint.h>
27
31
static
uint8_t *
__sbrk_heap_end
=
NULL
;
32
54
void
*
_sbrk
(ptrdiff_t incr)
55
{
56
extern
uint8_t _end;
/* Symbol defined in the linker script */
57
extern
uint8_t _estack;
/* Symbol defined in the linker script */
58
extern
uint32_t _Min_Stack_Size;
/* Symbol defined in the linker script */
59
const
uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size;
60
const
uint8_t *max_heap = (uint8_t *)stack_limit;
61
uint8_t *prev_heap_end;
62
63
/* Initialize heap end at first call */
64
if
(
NULL
==
__sbrk_heap_end
)
65
{
66
__sbrk_heap_end
= &_end;
67
}
68
69
/* Protect heap from growing into the reserved MSP stack */
70
if
(
__sbrk_heap_end
+ incr > max_heap)
71
{
72
errno
= ENOMEM;
73
return
(
void
*)-1;
74
}
75
76
prev_heap_end =
__sbrk_heap_end
;
77
__sbrk_heap_end
+= incr;
78
79
return
(
void
*)prev_heap_end;
80
}
NULL
#define NULL
Definition:
porcupine/demo/c/dr_libs/tests/external/miniaudio/extras/speex_resampler/thirdparty/resample.c:92
errno
int errno
__sbrk_heap_end
static uint8_t * __sbrk_heap_end
Definition:
stm32h747/stm32h747i-disco/CM7/Src/sysmem.c:31
_sbrk
void * _sbrk(ptrdiff_t incr)
_sbrk() allocates memory to the newlib heap and is used by malloc and others from the C library
Definition:
stm32h747/stm32h747i-disco/CM7/Src/sysmem.c:54
picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:14:55