home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 2
/
goldfish_vol2_cd1.bin
/
files
/
comm
/
misc
/
cyberpager
/
source
/
include
/
memory.h
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-20
|
740b
|
39 lines
/*
* these routines will use pooled memory under V39 or higher or standard
* memory routines when running under earlier versions of the OS. We lock
* semaphores as a means to prevent multiple people from stomping on the
* pool handles concurrently.
*/
extern APTR pool;
static void *__inline MyAllocVec(ULONG size)
{
UBYTE *memory;
size += sizeof(ULONG);
memory = AllocPooled(pool, size);
if (!memory)
return NULL;
*((ULONG *) memory) = size;
return (void *)(memory + sizeof(ULONG));
}
static void __inline MyFreeVec(void *memory)
{
void *realMemory;
ULONG size;
if (!memory)
return;
realMemory = (UBYTE *) memory - sizeof(ULONG);
size = *((ULONG *) realMemory);
FreePooled(pool, realMemory, size);
}