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.

229 lines
5.0 KiB

  1. //================================================================================
  2. // Copyright (C) 1997 Microsoft Corporation
  3. // Author: RameshV
  4. // Description: Routines to recursively free objects
  5. //================================================================================
  6. #include <mm.h>
  7. #include <winbase.h>
  8. #include <array.h>
  9. #include <opt.h>
  10. #include <optl.h>
  11. #include <optclass.h>
  12. #include <bitmask.h>
  13. #include <range.h>
  14. #include <reserve.h>
  15. #include <subnet.h>
  16. #include <optdefl.h>
  17. #include <classdefl.h>
  18. #include <oclassdl.h>
  19. #include <sscope.h>
  20. #include <server.h>
  21. #include <address.h>
  22. //BeginExport(typedef)
  23. typedef VOID (*ARRAY_FREE_FN)(LPVOID MemObject);
  24. //EndExport(typedef)
  25. //BeginExport(function)
  26. VOID
  27. MemArrayFree(
  28. IN OUT PARRAY Array,
  29. IN ARRAY_FREE_FN Function
  30. ) //EndExport(function)
  31. {
  32. ARRAY_LOCATION Loc;
  33. DWORD Error;
  34. LPVOID Element;
  35. Error = MemArrayInitLoc(Array, &Loc);
  36. while(ERROR_FILE_NOT_FOUND != Error) {
  37. Require(ERROR_SUCCESS == Error);
  38. Error = MemArrayGetElement(Array, &Loc, &Element);
  39. Require(ERROR_SUCCESS == Error && Element);
  40. Function(Element);
  41. Error = MemArrayNextLoc(Array, &Loc);
  42. }
  43. Require(ERROR_FILE_NOT_FOUND == Error);
  44. Error = MemArrayCleanup(Array);
  45. Require(ERROR_SUCCESS == Error);
  46. }
  47. //BeginExport(function)
  48. VOID
  49. MemOptFree(
  50. IN OUT PM_OPTION Opt
  51. ) //EndExport(function)
  52. {
  53. MemFree(Opt);
  54. }
  55. //BeginExport(function)
  56. VOID
  57. MemOptListFree(
  58. IN OUT PM_OPTLIST OptList
  59. ) //EndExport(function)
  60. {
  61. MemArrayFree(OptList, MemOptFree);
  62. }
  63. //BeginExport(function)
  64. VOID
  65. MemOptClassOneFree(
  66. IN OUT PM_ONECLASS_OPTLIST OptClassOne
  67. ) //EndExport(function)
  68. {
  69. MemOptListFree(&OptClassOne->OptList);
  70. MemFree(OptClassOne);
  71. }
  72. //BeginExport(function)
  73. VOID
  74. MemOptClassFree(
  75. IN OUT PM_OPTCLASS Options
  76. ) //EndExport(function)
  77. {
  78. MemArrayFree(&Options->Array, MemOptClassOneFree);
  79. }
  80. VOID
  81. MemBitMaskFree(
  82. IN OUT PM_BITMASK BitMask
  83. ) //EndExport(Function)
  84. {
  85. MemBitCleanup(BitMask);
  86. }
  87. //BeginExport(function)
  88. VOID
  89. MemRangeFree(
  90. IN OUT PM_RANGE Range
  91. ) //EndExport(function)
  92. {
  93. MemOptClassFree(&Range->Options);
  94. MemBitMaskFree(Range->BitMask);
  95. MemFree(Range);
  96. }
  97. //BeginExport(function)
  98. VOID
  99. MemExclusionFree(
  100. IN OUT PM_EXCL Excl
  101. ) //EndExport(function)
  102. {
  103. MemFree(Excl);
  104. }
  105. //BeginExport(function)
  106. VOID
  107. MemReservationFree(
  108. IN OUT PM_RESERVATION Reservation
  109. ) //EndExport(function)
  110. {
  111. MemOptClassFree(&Reservation->Options);
  112. MemFree(Reservation);
  113. }
  114. //BeginExport(function)
  115. VOID
  116. MemReservationsFree(
  117. IN OUT PM_RESERVATIONS Reservations
  118. ) //EndExport(function)
  119. {
  120. MemArrayFree(Reservations, MemReservationFree);
  121. }
  122. //BeginExport(function)
  123. VOID
  124. MemSubnetFree(
  125. IN OUT PM_SUBNET Subnet
  126. )//EndExport(function)
  127. {
  128. MemOptClassFree(&Subnet->Options);
  129. MemArrayFree(&Subnet->Ranges, MemRangeFree);
  130. MemArrayFree(&Subnet->Exclusions, MemExclusionFree);
  131. MemReservationsFree(&Subnet->Reservations);
  132. MemFree(Subnet);
  133. }
  134. //BeginExport(function)
  135. VOID
  136. MemMScopeFree(
  137. IN OUT PM_MSCOPE MScope
  138. )//EndExport(function)
  139. {
  140. MemSubnetFree(MScope);
  141. }
  142. //BeginExport(function)
  143. VOID
  144. MemOptDefFree(
  145. IN OUT PM_OPTDEF OptDef
  146. ) //EndExport(function)
  147. {
  148. MemFree(OptDef);
  149. }
  150. //BeginExport(function)
  151. VOID
  152. MemOptDefListFree(
  153. IN OUT PM_OPTCLASSDEFL_ONE OptClassDefListOne
  154. ) //EndExport(function)
  155. {
  156. MemArrayFree(&OptClassDefListOne->OptDefList.OptDefArray, MemOptDefFree);
  157. MemFree(OptClassDefListOne);
  158. }
  159. //BeginExport(function)
  160. VOID
  161. MemOptClassDefListFree(
  162. IN OUT PM_OPTCLASSDEFLIST OptClassDefList
  163. ) //EndExport(function)
  164. {
  165. MemArrayFree(&OptClassDefList->Array, MemOptDefListFree);
  166. }
  167. //BeginExport(function)
  168. VOID
  169. MemClassDefFree(
  170. IN OUT PM_CLASSDEF ClassDef
  171. ) //EndExport(function)
  172. {
  173. MemFree(ClassDef);
  174. }
  175. //BeginExport(function)
  176. VOID
  177. MemClassDefListFree(
  178. IN OUT PM_CLASSDEFLIST ClassDefList
  179. )//EndExport(function)
  180. {
  181. MemArrayFree(&ClassDefList->ClassDefArray, MemClassDefFree);
  182. }
  183. //BeginExport(function)
  184. VOID
  185. MemServerFree(
  186. IN OUT PM_SERVER Server
  187. ) //EndExport(function)
  188. {
  189. MemArrayFree(&Server->Subnets, MemSubnetFree);
  190. MemArrayFree(&Server->MScopes, MemMScopeFree);
  191. MemOptClassFree(&Server->Options);
  192. MemOptClassDefListFree(&Server->OptDefs);
  193. MemClassDefListFree(&Server->ClassDefs);
  194. MemFree(Server);
  195. }
  196. //================================================================================
  197. // end of file
  198. //================================================================================