[NTOS:IOPNP] Both PNP_PROPERTY_REMOVAL_POLICY_OVERRIDE and PNP_PROPERTY_LOCATION_PATH...
[reactos.git] / sdk / lib / dnslib / 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