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.

55 lines
1.2 KiB

  1. /*++
  2. Copyright (C) 1992-2001 Microsoft Corporation
  3. Module Name:
  4. PLEX.CPP
  5. Abstract:
  6. History:
  7. --*/
  8. // This is a part of the Microsoft Foundation Classes C++ library.
  9. // Copyright (C) 1992-1993 Microsoft Corporation
  10. // All rights reserved.
  11. //
  12. // This source code is only intended as a supplement to the
  13. // Microsoft Foundation Classes Reference and Microsoft
  14. // QuickHelp and/or WinHelp documentation provided with the library.
  15. // See these sources for detailed information regarding the
  16. // Microsoft Foundation Classes product.
  17. #include "precomp.h"
  18. #define ASSERT(x)
  19. #define ASSERT_VALID(x)
  20. #include "plex.h"
  21. CPlex* CPlex::Create(CPlex*& pHead, UINT nMax, UINT cbElement)
  22. {
  23. ASSERT(nMax > 0 && cbElement > 0);
  24. CPlex* p = (CPlex*) new BYTE[sizeof(CPlex) + nMax * cbElement];
  25. // may throw exception
  26. p->nMax = nMax;
  27. p->nCur = 0;
  28. p->pNext = pHead;
  29. pHead = p; // change head (adds in reverse order for simplicity)
  30. return p;
  31. }
  32. void CPlex::FreeDataChain() // free this one and links
  33. {
  34. CPlex* p = this;
  35. while (p != NULL)
  36. {
  37. BYTE* bytes = (BYTE*) p;
  38. CPlex* pNext = p->pNext;
  39. delete bytes;
  40. p = pNext;
  41. }
  42. }