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.

43 lines
800 B

  1. //
  2. // plex.cpp
  3. //
  4. // CPlex
  5. //
  6. #include "private.h"
  7. #include "template.h"
  8. /////////////////////////////////////////////////////////////////////////////
  9. // CPlex
  10. CPlex* PASCAL
  11. CPlex::Create(
  12. CPlex*& pHead,
  13. UINT nMax,
  14. UINT cbElement
  15. )
  16. {
  17. ASSERT(nMax > 0 && cbElement > 0);
  18. CPlex* p = (CPlex*) new BYTE[sizeof(CPlex) + nMax * cbElement];
  19. // may throw exception
  20. if ( p == NULL )
  21. return NULL;
  22. p->pNext = pHead;
  23. pHead = p; // change head (adds in reverse order for simplicity)
  24. return p;
  25. }
  26. void
  27. CPlex::FreeDataChain(
  28. )
  29. {
  30. CPlex* p = this;
  31. while (p != NULL) {
  32. BYTE* bytes = (BYTE*) p;
  33. CPlex* pNext = p->pNext;
  34. delete[] bytes;
  35. p = pNext;
  36. }
  37. }