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.

98 lines
1.9 KiB

  1. /***
  2. *contain.cpp - RTC support
  3. *
  4. * Copyright (c) 1998-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *
  7. *Revision History:
  8. * 07-28-98 JWM Module incorporated into CRTs (from KFrei)
  9. * 11-03-98 KBF added throw() to eliminate C++ EH code
  10. * 05-11-99 KBF Error if RTC support define not enabled
  11. * 05-26-99 KBF Added _RTC_ prefix, _RTC_ADVMEM stuff
  12. *
  13. ****/
  14. #ifndef _RTC
  15. #error RunTime Check support not enabled!
  16. #endif
  17. #include "rtcpriv.h"
  18. #ifdef _RTC_ADVMEM
  19. _RTC_Container *
  20. _RTC_Container::AddChild(_RTC_HeapBlock *hb) throw()
  21. {
  22. if (kids)
  23. {
  24. _RTC_Container *p = kids->get(hb);
  25. if (p)
  26. return p->AddChild(hb);
  27. kids->add(hb);
  28. } else
  29. {
  30. kids = new _RTC_BinaryTree(new _RTC_Container(hb));
  31. }
  32. return this;
  33. }
  34. _RTC_Container *
  35. _RTC_Container::DelChild(_RTC_HeapBlock* hb) throw()
  36. {
  37. if (kids)
  38. {
  39. _RTC_Container *p = kids->get(hb);
  40. if (p)
  41. {
  42. if (p->inf == hb) {
  43. kids->del(hb)->kill();
  44. return this;
  45. } else
  46. return p->DelChild(hb);
  47. }
  48. kids->del(hb);
  49. return this;
  50. } else
  51. return 0;
  52. }
  53. _RTC_Container *
  54. _RTC_Container::FindChild(_RTC_HeapBlock *i) throw()
  55. {
  56. if (inf == i)
  57. return this;
  58. else if (kids)
  59. {
  60. _RTC_Container *res = kids->get(i);
  61. if (res)
  62. return res->FindChild(i);
  63. }
  64. return 0;
  65. }
  66. void
  67. _RTC_Container::kill() throw()
  68. {
  69. if (kids)
  70. {
  71. _RTC_BinaryTree::iter i;
  72. for (_RTC_Container *c = kids->FindFirst(&i); c; c = kids->FindNext(&i))
  73. c->kill();
  74. delete kids;
  75. kids = 0;
  76. }
  77. if (inf)
  78. {
  79. delete inf;
  80. inf = 0;
  81. }
  82. }
  83. #endif // _RTC_ADVMEM