Source code of Windows XP (NT5)
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.

45 lines
1.2 KiB

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and Microsoft
  7. // QuickHelp documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10. #include "headers.cxx"
  11. #pragma hdrstop
  12. //#include <ole2int.h>
  13. #include "plex.h"
  14. // Collection support
  15. #define CairoleAssert(x) thkAssert(x)
  16. CPlex FAR* CPlex::Create(CPlex FAR* FAR& pHead, UINT nMax, UINT cbElement)
  17. {
  18. CairoleAssert(nMax > 0 && cbElement > 0);
  19. CPlex FAR* p = (CPlex FAR*)CoTaskMemAlloc(sizeof(CPlex) + nMax * cbElement);
  20. if (p == NULL)
  21. return NULL;
  22. p->nMax = nMax;
  23. p->nCur = 0;
  24. p->pNext = pHead;
  25. pHead = p; // change head (adds in reverse order for simplicity)
  26. return p;
  27. }
  28. void CPlex::FreeDataChain() // free this one and links
  29. {
  30. CPlex FAR* pThis;
  31. CPlex FAR* pNext;
  32. for (pThis = this; pThis != NULL; pThis = pNext) {
  33. pNext = pThis->pNext;
  34. pThis->pNext = NULL; // So compiler won't do nasty optimizations
  35. CoTaskMemFree(pThis);
  36. }
  37. }