#include <sys/types.h>
#include <sys/errno.h>

#include "plasma.h"

extern int _end;
static int dataend = (int)&_end;

void *sbrk(ptrdiff_t incr) {
	void *tmp = (void*)dataend;

	if (dataend + incr < (MEM_SIZE-STACK_SIZE)) {
		dataend += incr;
		return tmp;
	}

	errno = ENOMEM;
	return (void*)-1;
}
