home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 20.ddi / MFC / SRC / PLEX.CP_ / PLEX.CP
Encoding:
Text File  |  1993-02-08  |  1.2 KB  |  49 lines

  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 and/or WinHelp 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. #include "plex.h"
  13.  
  14. // Collection support
  15. #ifdef AFX_COLL_SEG
  16. #pragma code_seg(AFX_COLL_SEG)
  17. #endif
  18.  
  19. #ifdef _DEBUG
  20. #undef THIS_FILE
  21. static char BASED_CODE THIS_FILE[] = __FILE__;
  22. #endif
  23.  
  24. #define new DEBUG_NEW
  25.  
  26. CPlex* PASCAL CPlex::Create(CPlex*& pHead, UINT nMax, UINT cbElement)
  27. {
  28.     ASSERT(nMax > 0 && cbElement > 0);
  29.     CPlex* p = (CPlex*) new BYTE[sizeof(CPlex) + nMax * cbElement];
  30.             // may throw exception
  31.     p->nMax = nMax;
  32.     p->nCur = 0;
  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.