plex.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 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 related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10. #include "stdafx.h"
  11. // Collection support
  12. #ifdef AFX_COLL_SEG
  13. #pragma code_seg(AFX_COLL_SEG)
  14. #endif
  15. #ifdef _DEBUG
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. #define new DEBUG_NEW
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CPlex
  22. CPlex* PASCAL CPlex::Create(CPlex*& pHead, UINT nMax, UINT cbElement)
  23. {
  24. ASSERT(nMax > 0 && cbElement > 0);
  25. CPlex* p = (CPlex*) new BYTE[sizeof(CPlex) + nMax * cbElement];
  26. // may throw exception
  27. p->pNext = pHead;
  28. pHead = p; // change head (adds in reverse order for simplicity)
  29. return p;
  30. }
  31. void CPlex::FreeDataChain() // free this one and links
  32. {
  33. CPlex* p = this;
  34. while (p != NULL)
  35. {
  36. BYTE* bytes = (BYTE*) p;
  37. CPlex* pNext = p->pNext;
  38. delete[] bytes;
  39. p = pNext;
  40. }
  41. }