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.

37 lines
928 B

  1. //-----------------------------------------------------------------------------
  2. // File: collections.cpp
  3. //
  4. // Desc: Contains all container templates used by the UI.
  5. //
  6. // Copyright (C) 1999-2000 Microsoft Corporation. All Rights Reserved.
  7. //-----------------------------------------------------------------------------
  8. #include "common.h"
  9. BOOL AfxIsValidAddress( const void* lp, UINT nBytes, BOOL bReadWrite)
  10. {
  11. return lp != NULL;
  12. }
  13. CPlex* PASCAL CPlex::Create(CPlex*& pHead, UINT nMax, UINT cbElement)
  14. {
  15. assert(nMax > 0 && cbElement > 0);
  16. CPlex* p = (CPlex*) new BYTE[sizeof(CPlex) + nMax * cbElement];
  17. // may throw exception
  18. p->pNext = pHead;
  19. pHead = p; // change head (adds in reverse order for simplicity)
  20. return p;
  21. }
  22. void CPlex::FreeDataChain() // free this one and links
  23. {
  24. CPlex* p = this;
  25. while (p != NULL)
  26. {
  27. BYTE* bytes = (BYTE*) p;
  28. CPlex* pNext = p->pNext;
  29. delete[] bytes;
  30. p = pNext;
  31. }
  32. }