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.

53 lines
1.3 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 <le2int.h>
  11. #pragma SEG(plex)
  12. #include "plex.h"
  13. ASSERTDATA
  14. // Collection support
  15. #ifdef OLE_COLL_SEG
  16. #pragma code_seg(OLE_COLL_SEG)
  17. #endif
  18. #pragma SEG(CPlex_Create)
  19. CPlex FAR* CPlex::Create(CPlex FAR* FAR& pHead, UINT nMax, UINT cbElement)
  20. {
  21. VDATEHEAP();
  22. Assert(nMax > 0 && cbElement > 0);
  23. CPlex FAR* p = (CPlex FAR*)PrivMemAlloc(sizeof(CPlex) + nMax * cbElement);
  24. if (p == NULL)
  25. return NULL;
  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. #pragma SEG(CPlex_FreeDataChain)
  33. void CPlex::FreeDataChain() // free this one and links
  34. {
  35. VDATEHEAP();
  36. CPlex FAR* pThis;
  37. CPlex FAR* pNext;
  38. for (pThis = this; pThis != NULL; pThis = pNext) {
  39. pNext = pThis->pNext;
  40. pThis->pNext = NULL; // So compiler won't do nasty optimizations
  41. PrivMemFree(pThis);
  42. }
  43. }