8db2f0abbb5367d985b8f6358c72c1d5c3200290
[reactos.git] / dll / win32 / mswsock / dns / memory.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS DNS Shared Library
4 * FILE: lib/dnslib/memory.c
5 * PURPOSE: DNS Memory Manager Implementation and Heap.
6 */
7
8 /* INCLUDES ******************************************************************/
9 #include "precomp.h"
10
11 /* DATA **********************************************************************/
12
13 typedef PVOID
14 (WINAPI *PDNS_ALLOC_FUNCTION)(IN SIZE_T Size);
15 typedef VOID
16 (WINAPI *PDNS_FREE_FUNCTION)(IN PVOID Buffer);
17
18 PDNS_ALLOC_FUNCTION pDnsAllocFunction;
19 PDNS_FREE_FUNCTION pDnsFreeFunction;
20
21 /* FUNCTIONS *****************************************************************/
22
23 VOID
24 WINAPI
25 Dns_Free(IN PVOID Address)
26 {
27 /* Check if whoever imported us specified a special free function */
28 if (pDnsFreeFunction)
29 {
30 /* Use it */
31 pDnsFreeFunction(Address);
32 }
33 else
34 {
35 /* Use our own */
36 LocalFree(Address);
37 }
38 }
39
40 PVOID
41 WINAPI
42 Dns_AllocZero(IN SIZE_T Size)
43 {
44 PVOID Buffer;
45
46 /* Check if whoever imported us specified a special allocation function */
47 if (pDnsAllocFunction)
48 {
49 /* Use it to allocate the memory */
50 Buffer = pDnsAllocFunction(Size);
51 if (Buffer)
52 {
53 /* Zero it out */
54 RtlZeroMemory(Buffer, Size);
55 }
56 }
57 else
58 {
59 /* Use our default */
60 Buffer = LocalAlloc(LMEM_ZEROINIT, Size);
61 }
62
63 /* Return the allocate pointer */
64 return Buffer;
65 }
66
67 /*
68 * COPYRIGHT: See COPYING in the top level directory
69 * PROJECT: ReactOS DNS Shared Library
70 * FILE: lib/dnslib/memory.c
71 * PURPOSE: DNS Memory Manager Implementation and Heap.
72 */
73
74 /* INCLUDES ******************************************************************/
75 #include "precomp.h"
76
77 /* DATA **********************************************************************/
78
79 typedef PVOID
80 (WINAPI *PDNS_ALLOC_FUNCTION)(IN SIZE_T Size);
81 typedef VOID
82 (WINAPI *PDNS_FREE_FUNCTION)(IN PVOID Buffer);
83
84 PDNS_ALLOC_FUNCTION pDnsAllocFunction;
85 PDNS_FREE_FUNCTION pDnsFreeFunction;
86
87 /* FUNCTIONS *****************************************************************/
88
89 VOID
90 WINAPI
91 Dns_Free(IN PVOID Address)
92 {
93 /* Check if whoever imported us specified a special free function */
94 if (pDnsFreeFunction)
95 {
96 /* Use it */
97 pDnsFreeFunction(Address);
98 }
99 else
100 {
101 /* Use our own */
102 LocalFree(Address);
103 }
104 }
105
106 PVOID
107 WINAPI
108 Dns_AllocZero(IN SIZE_T Size)
109 {
110 PVOID Buffer;
111
112 /* Check if whoever imported us specified a special allocation function */
113 if (pDnsAllocFunction)
114 {
115 /* Use it to allocate the memory */
116 Buffer = pDnsAllocFunction(Size);
117 if (Buffer)
118 {
119 /* Zero it out */
120 RtlZeroMemory(Buffer, Size);
121 }
122 }
123 else
124 {
125 /* Use our default */
126 Buffer = LocalAlloc(LMEM_ZEROINIT, Size);
127 }
128
129 /* Return the allocate pointer */
130 return Buffer;
131 }
132
133 /*
134 * COPYRIGHT: See COPYING in the top level directory
135 * PROJECT: ReactOS DNS Shared Library
136 * FILE: lib/dnslib/memory.c
137 * PURPOSE: DNS Memory Manager Implementation and Heap.
138 */
139
140 /* INCLUDES ******************************************************************/
141 #include "precomp.h"
142
143 /* DATA **********************************************************************/
144
145 typedef PVOID
146 (WINAPI *PDNS_ALLOC_FUNCTION)(IN SIZE_T Size);
147 typedef VOID
148 (WINAPI *PDNS_FREE_FUNCTION)(IN PVOID Buffer);
149
150 PDNS_ALLOC_FUNCTION pDnsAllocFunction;
151 PDNS_FREE_FUNCTION pDnsFreeFunction;
152
153 /* FUNCTIONS *****************************************************************/
154
155 VOID
156 WINAPI
157 Dns_Free(IN PVOID Address)
158 {
159 /* Check if whoever imported us specified a special free function */
160 if (pDnsFreeFunction)
161 {
162 /* Use it */
163 pDnsFreeFunction(Address);
164 }
165 else
166 {
167 /* Use our own */
168 LocalFree(Address);
169 }
170 }
171
172 PVOID
173 WINAPI
174 Dns_AllocZero(IN SIZE_T Size)
175 {
176 PVOID Buffer;
177
178 /* Check if whoever imported us specified a special allocation function */
179 if (pDnsAllocFunction)
180 {
181 /* Use it to allocate the memory */
182 Buffer = pDnsAllocFunction(Size);
183 if (Buffer)
184 {
185 /* Zero it out */
186 RtlZeroMemory(Buffer, Size);
187 }
188 }
189 else
190 {
191 /* Use our default */
192 Buffer = LocalAlloc(LMEM_ZEROINIT, Size);
193 }
194
195 /* Return the allocate pointer */
196 return Buffer;
197 }
198
199 /*
200 * COPYRIGHT: See COPYING in the top level directory
201 * PROJECT: ReactOS DNS Shared Library
202 * FILE: lib/dnslib/memory.c
203 * PURPOSE: DNS Memory Manager Implementation and Heap.
204 */
205
206 /* INCLUDES ******************************************************************/
207 #include "precomp.h"
208
209 /* DATA **********************************************************************/
210
211 typedef PVOID
212 (WINAPI *PDNS_ALLOC_FUNCTION)(IN SIZE_T Size);
213 typedef VOID
214 (WINAPI *PDNS_FREE_FUNCTION)(IN PVOID Buffer);
215
216 PDNS_ALLOC_FUNCTION pDnsAllocFunction;
217 PDNS_FREE_FUNCTION pDnsFreeFunction;
218
219 /* FUNCTIONS *****************************************************************/
220
221 VOID
222 WINAPI
223 Dns_Free(IN PVOID Address)
224 {
225 /* Check if whoever imported us specified a special free function */
226 if (pDnsFreeFunction)
227 {
228 /* Use it */
229 pDnsFreeFunction(Address);
230 }
231 else
232 {
233 /* Use our own */
234 LocalFree(Address);
235 }
236 }
237
238 PVOID
239 WINAPI
240 Dns_AllocZero(IN SIZE_T Size)
241 {
242 PVOID Buffer;
243
244 /* Check if whoever imported us specified a special allocation function */
245 if (pDnsAllocFunction)
246 {
247 /* Use it to allocate the memory */
248 Buffer = pDnsAllocFunction(Size);
249 if (Buffer)
250 {
251 /* Zero it out */
252 RtlZeroMemory(Buffer, Size);
253 }
254 }
255 else
256 {
257 /* Use our default */
258 Buffer = LocalAlloc(LMEM_ZEROINIT, Size);
259 }
260
261 /* Return the allocate pointer */
262 return Buffer;
263 }
264