3 /* brk is handled entirely within the C library. This limits METAL programs that
4 * use the C library to be disallowed from dynamically allocating memory
5 * without talking to the C library, but that sounds like a sane way to go
6 * about it. Note that there is no error checking anywhere in this file, users
7 * will simply get the relevant error when actually trying to use the memory
8 * that's been allocated. */
9 extern char metal_segment_heap_target_start;
10 extern char metal_segment_heap_target_end;
11 static char *brk = &metal_segment_heap_target_start;
25 /* If __heap_size == 0, we can't allocate memory on the heap */
26 if(&metal_segment_heap_target_start == &metal_segment_heap_target_end) {
30 /* Don't move the break past the end of the heap */
31 if ((brk + incr) < &metal_segment_heap_target_end) {
34 brk = &metal_segment_heap_target_end;