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.

49 lines
1.1 KiB

  1. /*
  2. * @(#)_rawstack.cxx 1.0 3/30/98
  3. *
  4. * Copyright (C) 1998,1999 Microsoft Corporation. All rights reserved. *
  5. */
  6. #include "stdinc.h"
  7. #include "core.hxx"
  8. #pragma hdrstop
  9. #include "_rawstack.hxx"
  10. //===========================================================================
  11. RawStack::RawStack(long entrySize, long growth)
  12. {
  13. _lEntrySize = entrySize;
  14. _pStack = NULL;
  15. _ncUsed = _ncSize = 0;
  16. _lGrowth = growth;
  17. }
  18. RawStack::~RawStack()
  19. {
  20. delete _pStack;
  21. }
  22. char*
  23. RawStack::__push()
  24. {
  25. // No magic object construction -- user has to do this.
  26. #ifdef FUSION_USE_OLD_XML_PARSER_SOURCE
  27. char* newStack = new_ne char[_lEntrySize * ( _ncSize + _lGrowth) ];
  28. #else
  29. char* newStack = NEW (char[_lEntrySize * ( _ncSize + _lGrowth) ]);
  30. #endif
  31. if (newStack == NULL)
  32. {
  33. return NULL;
  34. }
  35. ::memset(newStack, 0, _lEntrySize * (_ncSize + _lGrowth));
  36. if (_ncUsed > 0)
  37. {
  38. ::memcpy(newStack, _pStack, _lEntrySize * _ncUsed);
  39. }
  40. _ncSize += _lGrowth;
  41. delete _pStack;
  42. _pStack = newStack;
  43. return &_pStack[_lEntrySize * _ncUsed++];
  44. }