You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.0 KiB
47 lines
1.0 KiB
//
|
|
// memcache.cpp
|
|
//
|
|
|
|
#include "private.h"
|
|
#include "memcache.h"
|
|
|
|
LONG g_lMemCacheMutex = -1;
|
|
|
|
//+---------------------------------------------------------------------------
|
|
//
|
|
// MemCache_New
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
MEMCACHE *MemCache_New(ULONG uMaxPtrs)
|
|
{
|
|
MEMCACHE *pmc;
|
|
ULONG uSize;
|
|
|
|
Assert(uMaxPtrs > 0);
|
|
|
|
uSize = sizeof(MEMCACHE) + uMaxPtrs*sizeof(void *) - sizeof(void *);
|
|
|
|
if ((pmc = (MEMCACHE *)cicMemAlloc(uSize)) == NULL)
|
|
return NULL;
|
|
|
|
pmc->uMaxPtrs = uMaxPtrs;
|
|
pmc->iNextFree = 0;
|
|
|
|
return pmc;
|
|
}
|
|
|
|
//+---------------------------------------------------------------------------
|
|
//
|
|
// MemCache_Delete
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
void MemCache_Delete(MEMCACHE *pMemCache)
|
|
{
|
|
while (pMemCache->iNextFree > 0)
|
|
{
|
|
cicMemFree(pMemCache->rgPtrs[--pMemCache->iNextFree]);
|
|
}
|
|
cicMemFree(pMemCache);
|
|
}
|