Category : C Source Code
Archive   : HEAPMAN.ZIP
Filename : NUHNDL.C
Output of file : NUHNDL.C contained in archive : HEAPMAN.ZIP
long *NuHndl(theSize)
int theSize;
/*
rets a hndl to a blk of mem of size "blk + hdr" if enough heap
space is available. Otherwise, it rets a NIL ptr. Note: in order to
access the data area of the allocated hndl, the user app must offset
by a value equal to the blk hdr in bytes.
calling params:
blk size in bytes
return params:
hndl | NIL
Author: Byro
Creation: 01/09/91
Modified: 01/21/91
Revision:
*/
{
int emptyHndl = ZERO;
long *aHndl = NIL;
unsigned long myTemp;
extern long gMPTsize,
*gTableSizeCountAdrs;
/* chk free space, if enough or ret location of free hndl */
if (ComputeFree((long) theSize, &emptyHndl) != NO_ERR)
return(NIL);
/* chk to see if mpt full and ret if true */
if (emptyHndl == ZERO)
return(NIL);
/* load hndl and adrs of mem; var myTemp needed to avoid add errs */
myTemp = (unsigned long) gTableSizeCountAdrs + (emptyHndl * BYTE_OFFSET);
aHndl = (long *) myTemp;
myTemp = (unsigned long) gTableSizeCountAdrs + ((gMPTsize + 1) * BYTE_OFFSET);
*aHndl = myTemp; /* free space above mpt */
/* setup data struct to nu blk */
if (UpdateBlk(aHndl, theSize) != NO_ERR)
return(NIL);
/* compact heap */
if (CompactHeap() != NO_ERR)
return(NIL);
return(aHndl);
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/