Category : C Source Code
Archive   : HEAPMAN.ZIP
Filename : INITHEAP.C
Output of file : INITHEAP.C contained in archive : HEAPMAN.ZIP
#include "mm.h"
long gMPTsize = ZERO,
*gTableSizeCountAdrs = NIL,
*gTopOfHeap = NIL;
InitHeap(BlockSize, TableSize)
long BlockSize, TableSize;
/*
Allocates and initializes the heap. Moreover, it also sets up the
Master Pointer Table (MPT) to the size specified by TableSize. Note:
table size must be a power of 2 or else it rets an error.
calling params:
heap size
number of handles in MPT
return params:
err | noErr
Author: Byro
Creation: 01/11/91
Modified: 01/21/91
Revision:
*/
{
char *theBlk = NIL; /* needed by mac 2 alloc non reloc blk */
unsigned long myTemp; /* used 2 avoid errs during computing adrses */
if (((TableSize +1) * BYTE_OFFSET) > BlockSize)
return(INIT_HEAP); /* err, not enough space */
if (IsEven(TableSize) == FALSE)
return(INIT_HEAP);
gMPTsize = TableSize;
theBlk = malloc((unsigned int) BlockSize);
gTableSizeCountAdrs = (long *) theBlk;
if (theBlk == NIL)
return(INIT_HEAP);
myTemp = (unsigned long) gTableSizeCountAdrs + (unsigned long) BlockSize;
gTopOfHeap = (long *) myTemp;
/* clr mpt table which consists of n + 1 elements */
ZeroStruct((char *) gTableSizeCountAdrs, (int) (gMPTsize + 1) * BYTE_OFFSET);
/* set mpt table count size */
*gTableSizeCountAdrs = gMPTsize;
return(NO_ERR); /* successs! */
}
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/