3 * Copyright (C) 1996, Onno Hovers, All rights reserved
5 * This software is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This software is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this software; see the file COPYING.LIB. If
17 * not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18 * Cambridge, MA 02139, USA.
20 * Win32 heap functions (HeapXXX).
25 * Adapted for the ReactOS system libraries by David Welch (welch@mcmail.com)
26 * Put the type definitions of the heap in a seperate header. Boudewijn Dekker
29 #include <ddk/ntddk.h>
30 #include <ntdll/rtl.h>
33 #include <kernel32/kernel32.h>
35 /*********************************************************************
36 * HeapCreate -- KERNEL32 *
37 *********************************************************************/
38 HANDLE STDCALL
HeapCreate(DWORD flags
, DWORD minsize
, DWORD maxsize
)
41 DPRINT("HeapCreate( 0x%lX, 0x%lX, 0x%lX )\n", flags
, minsize
, maxsize
);
42 return(RtlCreateHeap(flags
, NULL
, maxsize
, minsize
, NULL
, NULL
));
45 /*********************************************************************
46 * HeapDestroy -- KERNEL32 *
47 *********************************************************************/
48 BOOL WINAPI
HeapDestroy(HANDLE hheap
)
50 return(RtlDestroyHeap(hheap
));
53 /*********************************************************************
54 * HeapAlloc -- KERNEL32 *
55 *********************************************************************/
56 LPVOID STDCALL
HeapAlloc(HANDLE hheap
, DWORD flags
, DWORD size
)
58 return(RtlAllocateHeap(hheap
, flags
, size
));
61 /*********************************************************************
62 * HeapReAlloc -- KERNEL32 *
63 *********************************************************************/
64 LPVOID STDCALL
HeapReAlloc(HANDLE hheap
, DWORD flags
, LPVOID ptr
, DWORD size
)
66 return(RtlReAllocHeap(hheap
, flags
, ptr
, size
));
69 /*********************************************************************
70 * HeapFree -- KERNEL32 *
71 *********************************************************************/
72 WINBOOL STDCALL
HeapFree(HANDLE hheap
, DWORD flags
, LPVOID ptr
)
74 return(RtlFreeHeap(hheap
, flags
, ptr
));
77 /*********************************************************************
78 * GetProcessHeap -- KERNEL32 *
79 *********************************************************************/
80 HANDLE WINAPI
GetProcessHeap(VOID
)
82 DPRINT("GetProcessHeap()\n");
83 return(RtlGetProcessHeap());
86 /********************************************************************
87 * GetProcessHeaps -- KERNEL32 *
89 * NOTE in Win95 this function is not implemented and just returns *
90 * ERROR_CALL_NOT_IMPLEMENTED *
91 ********************************************************************/
92 DWORD WINAPI
GetProcessHeaps(DWORD maxheaps
, PHANDLE phandles
)
96 /*********************************************************************
97 * HeapLock -- KERNEL32 *
98 *********************************************************************/
99 BOOL WINAPI
HeapLock(HANDLE hheap
)
101 return(RtlLockHeap(hheap
));
104 /*********************************************************************
105 * HeapUnlock -- KERNEL32 *
106 *********************************************************************/
107 BOOL WINAPI
HeapUnlock(HANDLE hheap
)
109 return(RtlUnlockHeap(hheap
));
112 /*********************************************************************
113 * HeapCompact -- KERNEL32 *
115 * NT uses this function to compact moveable blocks and other things *
116 * Here it does not compact, but it finds the largest free region *
117 *********************************************************************/
118 UINT
HeapCompact(HANDLE hheap
, DWORD flags
)
120 return(RtlCompactHeap(hheap
, flags
));
123 /*********************************************************************
124 * HeapSize -- KERNEL32 *
125 *********************************************************************/
126 DWORD WINAPI
HeapSize(HANDLE hheap
, DWORD flags
, LPCVOID pmem
)
128 return(RtlSizeHeap(hheap
, flags
, pmem
));
131 /*********************************************************************
132 * HeapValidate -- KERNEL32 *
134 * NOTE: only implemented in NT *
135 *********************************************************************/
136 BOOL WINAPI
HeapValidate(HANDLE hheap
, DWORD flags
, LPCVOID pmem
)
138 return(RtlValidateHeap(hheap
, flags
, pmem
));