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.
8 /* INCLUDES ******************************************************************/
11 /* DATA **********************************************************************/
14 (WINAPI
*PDNS_ALLOC_FUNCTION
)(IN SIZE_T Size
);
16 (WINAPI
*PDNS_FREE_FUNCTION
)(IN PVOID Buffer
);
18 PDNS_ALLOC_FUNCTION pDnsAllocFunction
;
19 PDNS_FREE_FUNCTION pDnsFreeFunction
;
21 /* FUNCTIONS *****************************************************************/
25 Dns_Free(IN PVOID Address
)
27 /* Check if whoever imported us specified a special free function */
31 pDnsFreeFunction(Address
);
42 Dns_AllocZero(IN SIZE_T Size
)
46 /* Check if whoever imported us specified a special allocation function */
47 if (pDnsAllocFunction
)
49 /* Use it to allocate the memory */
50 Buffer
= pDnsAllocFunction(Size
);
54 RtlZeroMemory(Buffer
, Size
);
60 Buffer
= LocalAlloc(LMEM_ZEROINIT
, Size
);
63 /* Return the allocate pointer */
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.
74 /* INCLUDES ******************************************************************/
77 /* DATA **********************************************************************/
80 (WINAPI
*PDNS_ALLOC_FUNCTION
)(IN SIZE_T Size
);
82 (WINAPI
*PDNS_FREE_FUNCTION
)(IN PVOID Buffer
);
84 PDNS_ALLOC_FUNCTION pDnsAllocFunction
;
85 PDNS_FREE_FUNCTION pDnsFreeFunction
;
87 /* FUNCTIONS *****************************************************************/
91 Dns_Free(IN PVOID Address
)
93 /* Check if whoever imported us specified a special free function */
97 pDnsFreeFunction(Address
);
108 Dns_AllocZero(IN SIZE_T Size
)
112 /* Check if whoever imported us specified a special allocation function */
113 if (pDnsAllocFunction
)
115 /* Use it to allocate the memory */
116 Buffer
= pDnsAllocFunction(Size
);
120 RtlZeroMemory(Buffer
, Size
);
125 /* Use our default */
126 Buffer
= LocalAlloc(LMEM_ZEROINIT
, Size
);
129 /* Return the allocate pointer */
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.
140 /* INCLUDES ******************************************************************/
143 /* DATA **********************************************************************/
146 (WINAPI
*PDNS_ALLOC_FUNCTION
)(IN SIZE_T Size
);
148 (WINAPI
*PDNS_FREE_FUNCTION
)(IN PVOID Buffer
);
150 PDNS_ALLOC_FUNCTION pDnsAllocFunction
;
151 PDNS_FREE_FUNCTION pDnsFreeFunction
;
153 /* FUNCTIONS *****************************************************************/
157 Dns_Free(IN PVOID Address
)
159 /* Check if whoever imported us specified a special free function */
160 if (pDnsFreeFunction
)
163 pDnsFreeFunction(Address
);
174 Dns_AllocZero(IN SIZE_T Size
)
178 /* Check if whoever imported us specified a special allocation function */
179 if (pDnsAllocFunction
)
181 /* Use it to allocate the memory */
182 Buffer
= pDnsAllocFunction(Size
);
186 RtlZeroMemory(Buffer
, Size
);
191 /* Use our default */
192 Buffer
= LocalAlloc(LMEM_ZEROINIT
, Size
);
195 /* Return the allocate pointer */
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.
206 /* INCLUDES ******************************************************************/
209 /* DATA **********************************************************************/
212 (WINAPI
*PDNS_ALLOC_FUNCTION
)(IN SIZE_T Size
);
214 (WINAPI
*PDNS_FREE_FUNCTION
)(IN PVOID Buffer
);
216 PDNS_ALLOC_FUNCTION pDnsAllocFunction
;
217 PDNS_FREE_FUNCTION pDnsFreeFunction
;
219 /* FUNCTIONS *****************************************************************/
223 Dns_Free(IN PVOID Address
)
225 /* Check if whoever imported us specified a special free function */
226 if (pDnsFreeFunction
)
229 pDnsFreeFunction(Address
);
240 Dns_AllocZero(IN SIZE_T Size
)
244 /* Check if whoever imported us specified a special allocation function */
245 if (pDnsAllocFunction
)
247 /* Use it to allocate the memory */
248 Buffer
= pDnsAllocFunction(Size
);
252 RtlZeroMemory(Buffer
, Size
);
257 /* Use our default */
258 Buffer
= LocalAlloc(LMEM_ZEROINIT
, Size
);
261 /* Return the allocate pointer */