home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / mfc / src / plex.cpp < prev    next >
C/C++ Source or Header  |  1998-06-16  |  1KB  |  49 lines

  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.  
  11. #include "stdafx.h"
  12.  
  13. // Collection support
  14. #ifdef AFX_COLL_SEG
  15. #pragma code_seg(AFX_COLL_SEG)
  16. #endif
  17.  
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22.  
  23. #define new DEBUG_NEW
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CPlex
  27.  
  28. CPlex* PASCAL CPlex::Create(CPlex*& pHead, UINT nMax, UINT cbElement)
  29. {
  30.     ASSERT(nMax > 0 && cbElement > 0);
  31.     CPlex* p = (CPlex*) new BYTE[sizeof(CPlex) + nMax * cbElement];
  32.             // may throw exception
  33.     p->pNext = pHead;
  34.     pHead = p;  // change head (adds in reverse order for simplicity)
  35.     return p;
  36. }
  37.  
  38. void CPlex::FreeDataChain()     // free this one and links
  39. {
  40.     CPlex* p = this;
  41.     while (p != NULL)
  42.     {
  43.         BYTE* bytes = (BYTE*) p;
  44.         CPlex* pNext = p->pNext;
  45.         delete[] bytes;
  46.         p = pNext;
  47.     }
  48. }
  49.