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.

51 lines
1.2 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. : _lEntrySize(entrySize), _lGrowth(growth), _pStack(NULL), _ncUsed(0), _ncSize(0)
  13. {
  14. }
  15. RawStack::~RawStack()
  16. {
  17. if (_pStack != NULL)
  18. {
  19. delete _pStack;
  20. _pStack = NULL;
  21. }
  22. }
  23. char*
  24. RawStack::__push()
  25. {
  26. // No magic object construction -- user has to do this.
  27. // NTRAID#NTBUG9 - 571792 - jonwis - 2002/04/25 - Dead code removal
  28. #ifdef FUSION_USE_OLD_XML_PARSER_SOURCE
  29. char* newStack = new_ne char[_lEntrySize * ( _ncSize + _lGrowth) ];
  30. #else
  31. char* newStack = NEW (char[_lEntrySize * ( _ncSize + _lGrowth) ]);
  32. #endif
  33. if (newStack == NULL)
  34. {
  35. return NULL;
  36. }
  37. ::memset(newStack, 0, _lEntrySize * (_ncSize + _lGrowth));
  38. if (_ncUsed > 0)
  39. {
  40. ::memcpy(newStack, _pStack, _lEntrySize * _ncUsed);
  41. }
  42. _ncSize += _lGrowth;
  43. delete _pStack;
  44. _pStack = newStack;
  45. return &_pStack[_lEntrySize * _ncUsed++];
  46. }