home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
262.lha
/
BlitLab_v1.4
/
mem.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-06-29
|
758b
|
40 lines
/*
* Memory allocation and deallocation for BlitLab.
*/
#include "structures.h"
struct memnode {
struct memnode * next ;
long size ;
} ;
static struct memnode *head ;
/*
* Replacement for AllocMem. If not enough memory, we exit.
*/
void *allocmem(size, type)
long size ;
long type ;
{
struct memnode *p ;
extern void *AllocMem() ;
p = (struct memnode *)AllocMem(size + sizeof(struct memnode), type) ;
if (p==NULL)
error("! out of memory") ;
p->size = size + sizeof(struct memnode) ;
p->next = head ;
head = p ;
return(p + 1) ;
}
/*
* Frees all allocated memory.
*/
freemem() {
struct memnode *p ;
while (head != NULL) {
p = head->next ;
FreeMem(head, head->size) ;
head = p ;
}
}