ffad20a220adfd3a190d302b85f5f7e0c7939e03
[reactos.git] / reactos / lib / kernel32 / mem / heap.c
1 /* $Id: heap.c,v 1.21 2002/09/08 10:22:43 chorns Exp $
2 *
3 * kernel/heap.c
4 * Copyright (C) 1996, Onno Hovers, All rights reserved
5 *
6 * This software is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This software is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this software; see the file COPYING.LIB. If
18 * not, write to the Free Software Foundation, Inc., 675 Mass Ave,
19 * Cambridge, MA 02139, USA.
20 *
21 * Win32 heap functions (HeapXXX).
22 *
23 */
24
25 /*
26 * Adapted for the ReactOS system libraries by David Welch (welch@mcmail.com)
27 * Put the type definitions of the heap in a seperate header. Boudewijn Dekker
28 */
29
30 #include <ddk/ntddk.h>
31 #include <ntdll/rtl.h>
32
33 #define NDEBUG
34 #include <kernel32/kernel32.h>
35
36 /*********************************************************************
37 * HeapCreate -- KERNEL32 *
38 *********************************************************************/
39 HANDLE STDCALL HeapCreate(DWORD flags, DWORD minsize, DWORD maxsize)
40 {
41
42 DPRINT("HeapCreate( 0x%lX, 0x%lX, 0x%lX )\n", flags, minsize, maxsize);
43 return(RtlCreateHeap(flags, NULL, maxsize, minsize, NULL, NULL));
44 }
45
46 /*********************************************************************
47 * HeapDestroy -- KERNEL32 *
48 *********************************************************************/
49 BOOL WINAPI HeapDestroy(HANDLE hheap)
50 {
51 return(RtlDestroyHeap(hheap));
52 }
53
54 /*********************************************************************
55 * GetProcessHeap -- KERNEL32 *
56 *********************************************************************/
57 HANDLE WINAPI GetProcessHeap(VOID)
58 {
59 DPRINT("GetProcessHeap()\n");
60 return(RtlGetProcessHeap());
61 }
62
63 /********************************************************************
64 * GetProcessHeaps -- KERNEL32 *
65 ********************************************************************/
66 DWORD WINAPI GetProcessHeaps(DWORD maxheaps, PHANDLE phandles )
67 {
68 return(RtlGetProcessHeaps(maxheaps, phandles));
69 }
70
71 /*********************************************************************
72 * HeapLock -- KERNEL32 *
73 *********************************************************************/
74 BOOL WINAPI HeapLock(HANDLE hheap)
75 {
76 return(RtlLockHeap(hheap));
77 }
78
79 /*********************************************************************
80 * HeapUnlock -- KERNEL32 *
81 *********************************************************************/
82 BOOL WINAPI HeapUnlock(HANDLE hheap)
83 {
84 return(RtlUnlockHeap(hheap));
85 }
86
87 /*********************************************************************
88 * HeapCompact -- KERNEL32 *
89 * *
90 * NT uses this function to compact moveable blocks and other things *
91 * Here it does not compact, but it finds the largest free region *
92 *********************************************************************/
93 UINT WINAPI HeapCompact(HANDLE hheap, DWORD flags)
94 {
95 return RtlCompactHeap(hheap, flags);
96 }
97
98 /*********************************************************************
99 * HeapValidate -- KERNEL32 *
100 *********************************************************************/
101 BOOL WINAPI HeapValidate(HANDLE hheap, DWORD flags, LPCVOID pmem)
102 {
103 return(RtlValidateHeap(hheap, flags, (PVOID)pmem));
104 }
105
106
107 DWORD
108 STDCALL
109 HeapCreateTagsW (
110 DWORD Unknown0,
111 DWORD Unknown1,
112 DWORD Unknown2,
113 DWORD Unknown3
114 )
115 {
116 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
117 return 0;
118 }
119
120
121 DWORD
122 STDCALL
123 HeapExtend (
124 DWORD Unknown0,
125 DWORD Unknown1,
126 DWORD Unknown2,
127 DWORD Unknown3
128 )
129 {
130 #if 0
131 NTSTATUS Status;
132
133 Status = RtlExtendHeap(Unknown1, Unknown2, Unknown3, Unknown4);
134 if (!NT_SUCCESS(Status))
135 {
136 SetLastErrorByStatus(Status);
137 return FALSE;
138 }
139 return TRUE;
140 #endif
141
142 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
143 return 0;
144 }
145
146
147 DWORD
148 STDCALL
149 HeapQueryTagW (
150 DWORD Unknown0,
151 DWORD Unknown1,
152 DWORD Unknown2,
153 DWORD Unknown3,
154 DWORD Unknown4
155 )
156 {
157 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
158 return 0;
159 }
160
161
162 DWORD
163 STDCALL
164 HeapSummary (
165 DWORD Unknown0,
166 DWORD Unknown1,
167 DWORD Unknown2
168 )
169 {
170 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
171 return 0;
172 }
173
174
175 DWORD
176 STDCALL
177 HeapUsage (
178 DWORD Unknown0,
179 DWORD Unknown1,
180 DWORD Unknown2,
181 DWORD Unknown3,
182 DWORD Unknown4
183 )
184 {
185 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
186 return 0;
187 }
188
189
190 WINBOOL
191 STDCALL
192 HeapWalk (
193 HANDLE hHeap,
194 LPPROCESS_HEAP_ENTRY lpEntry
195 )
196 {
197 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
198 return FALSE;
199 }
200
201
202 /* EOF */