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.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 <windows.h>
  11. #include <ole2.h>
  12. #include <ole2sp.h>
  13. #include <olecoll.h>
  14. #include <memctx.hxx>
  15. #include "plex.h"
  16. ASSERTDATA
  17. CPlex FAR* CPlex::Create(CPlex FAR* FAR& pHead, DWORD mp, UINT nMax, UINT cbElement)
  18. {
  19. AssertSz(nMax > 0 && cbElement > 0,0);
  20. CPlex FAR* p = (CPlex FAR*)CoMemAlloc(sizeof(CPlex) + nMax * cbElement, mp, NULL);
  21. if (p == NULL)
  22. return NULL;
  23. p->nMax = nMax;
  24. p->nCur = 0;
  25. p->pNext = pHead;
  26. pHead = p; // change head (adds in reverse order for simplicity)
  27. return p;
  28. }
  29. void CPlex::FreeDataChain(DWORD mp) // free this one and links
  30. {
  31. CPlex FAR* pThis;
  32. CPlex FAR* pNext;
  33. for (pThis = this; pThis != NULL; pThis = pNext) {
  34. pNext = pThis->pNext;
  35. pThis->pNext = NULL; // So compiler won't do nasty optimizations
  36. CoMemFree(pThis, mp);
  37. }
  38. }