home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 7
/
FreshFishVol7.bin
/
bbs
/
comm
/
cyberpager-1.5.lha
/
CyberPager
/
source
/
library
/
memory.h
< prev
next >
Wrap
Text File
|
1993-06-13
|
839b
|
41 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.
*/
static void *__inline MyAllocVec(ULONG size)
{
UBYTE *memory;
size += sizeof(ULONG);
ObtainSemaphore(&poolSema);
memory = AllocPooled(pool, size);
ReleaseSemaphore(&poolSema);
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);
ObtainSemaphore(&poolSema);
FreePooled(pool, realMemory, size);
ReleaseSemaphore(&poolSema);
}