summaryrefslogtreecommitdiff
path: root/bsp/libwrap/sys/sbrk.c
blob: 6e6b36ab9861cfd2f6a9d2ae4a932a659c65ac5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* See LICENSE of license details. */

#include <stddef.h>

void *__wrap_sbrk(ptrdiff_t incr)
{
  extern char _end[];
  extern char _heap_end[];
  static char *curbrk = _end;

  if ((curbrk + incr < _end) || (curbrk + incr > _heap_end))
    return NULL - 1;

  curbrk += incr;
  return curbrk - incr;
}