ack/mach/minix/libsys/brk.c

35 lines
524 B
C
Raw Normal View History

1988-04-19 09:34:37 +00:00
#include "lib.h"
extern char *brksize;
PUBLIC char *brk(addr)
char *addr;
{
int k;
k = callm1(MM, BRK, 0, 0, 0, addr, NIL_PTR, NIL_PTR);
if (k == OK) {
brksize = M.m2_p1;
return(NIL_PTR);
} else {
return( (char*) -1 );
}
}
PUBLIC char *sbrk(incr)
int incr;
{
char *newsize, *oldsize;
oldsize = brksize;
newsize = brksize + incr;
1989-11-03 09:25:46 +00:00
if (incr > 0 && newsize < oldsize || incr < 0 && newsize > oldsize)
return( (char *) -1);
1988-04-19 09:34:37 +00:00
if (brk(newsize) == 0)
return(oldsize);
else
return( (char *) -1 );
}