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:
47
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/clib/sbrk.c
Normal file
47
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/clib/sbrk.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* s b r k F u n c t i o n
|
||||
* -------------------------
|
||||
* Copyright 1982 by Digital Research Inc. All rights reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Last modified:
|
||||
* 1/84 whf refresh include files for 68K (sbrk in asm for 8086)
|
||||
****************************************************************************/
|
||||
#include "portab.h"
|
||||
#include "osif.h"
|
||||
#include "osiferr.h"
|
||||
#include "errno.h"
|
||||
/****************************/
|
||||
EXTERN BYTE *_break; /* Old break address */
|
||||
/****************************/
|
||||
BYTE * sbrk(incr) /* CLEAR FUNCTION ***********/
|
||||
WORD incr; /* Incremental storage */
|
||||
/* */
|
||||
{ /****************************/
|
||||
REG BYTE *t1,*t2; /* Temporary */
|
||||
REG LONG inc; /* Temp size increment */
|
||||
inc = ((LONG)incr) & 0xffffL; /* Un sign-extend */
|
||||
if(inc & 1) /* Disallow odd incr's */
|
||||
inc++; /* Round up to next */
|
||||
/* */
|
||||
t1 = _break; /* Save the old break */
|
||||
t2 = _break + inc; /* New break value */
|
||||
/****************************/
|
||||
if(brk(t2) == FAILURE) /* Allocate */
|
||||
RETERR(FAILURE,ENOMEM); /* Can't */
|
||||
/****************************/
|
||||
return(t1); /* And return */
|
||||
} /****************************/
|
Reference in New Issue
Block a user