Leaked source code of windows server 2003
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

  1. //
  2. // memcache.cpp
  3. //
  4. #include "private.h"
  5. #include "memcache.h"
  6. LONG g_lMemCacheMutex = -1;
  7. //+---------------------------------------------------------------------------
  8. //
  9. // MemCache_New
  10. //
  11. //----------------------------------------------------------------------------
  12. MEMCACHE *MemCache_New(ULONG uMaxPtrs)
  13. {
  14. MEMCACHE *pmc;
  15. ULONG uSize;
  16. Assert(uMaxPtrs > 0);
  17. uSize = sizeof(MEMCACHE) + uMaxPtrs*sizeof(void *) - sizeof(void *);
  18. if ((pmc = (MEMCACHE *)cicMemAlloc(uSize)) == NULL)
  19. return NULL;
  20. pmc->uMaxPtrs = uMaxPtrs;
  21. pmc->iNextFree = 0;
  22. return pmc;
  23. }
  24. //+---------------------------------------------------------------------------
  25. //
  26. // MemCache_Delete
  27. //
  28. //----------------------------------------------------------------------------
  29. void MemCache_Delete(MEMCACHE *pMemCache)
  30. {
  31. while (pMemCache->iNextFree > 0)
  32. {
  33. cicMemFree(pMemCache->rgPtrs[--pMemCache->iNextFree]);
  34. }
  35. cicMemFree(pMemCache);
  36. }