23 lines
356 B
C
23 lines
356 B
C
#include "unistd.h"
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
void *__curr_brk = NULL;
|
|
|
|
void *sbrk(intptr_t increment)
|
|
{
|
|
if (!__curr_brk) {
|
|
brk(NULL);
|
|
}
|
|
|
|
uintptr_t end = (uintptr_t)__curr_brk + increment;
|
|
void *start = __curr_brk;
|
|
int res = brk((void *)end);
|
|
|
|
if (res == -1) {
|
|
return NULL;
|
|
}
|
|
|
|
return start;
|
|
}
|