mirror of
https://github.com/SEPPDROID/Digital-Research-Source-Code.git
synced 2025-10-23 08:24:18 +00:00
Upload
Digital Research
This commit is contained in:
40
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v101/klib/sbrk.c
Normal file
40
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v101/klib/sbrk.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* s b r k F u n c t i o n */
|
||||
/* ------------------------- */
|
||||
/* */
|
||||
/* The "sbrk" function is used to allocate memory dynamically. */
|
||||
/* */
|
||||
/* Calling Sequence: */
|
||||
/* */
|
||||
/* addr = sbrk(incr); */
|
||||
/* */
|
||||
/* Where: */
|
||||
/* incr Is the incremental number of bytes to be added to */
|
||||
/* the program heap area. */
|
||||
/* */
|
||||
/* addr Is the beginning address of the allocated area. */
|
||||
/* -1 is returned if allocation failed */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
#include "stdio.h"
|
||||
#include "cpm.h"
|
||||
EXTERN BYTE *_break; /* Old break address */
|
||||
/****************************/
|
||||
BYTE *sbrk(incr) /* */
|
||||
WORD incr; /* Incremental storage */
|
||||
/* */
|
||||
{ /****************************/
|
||||
REG BYTE *t1; /* Temporary */
|
||||
if(incr & 1) /* Disallow odd incr's */
|
||||
incr++; /* Round up to next */
|
||||
/* */
|
||||
t1 = _break + incr; /* New break value */
|
||||
/****************************/
|
||||
if(brk(t1) == FAILURE) /* Allocate */
|
||||
return(FAILURE); /* Can't */
|
||||
/****************************/
|
||||
t1 = _break; /* Save old break */
|
||||
_break += incr; /* Set new break */
|
||||
return(t1); /* And return */
|
||||
} /****************************/
|
Reference in New Issue
Block a user