*** empty log message ***
[reactos.git] / reactos / lib / kernel32 / mem / heap.c
1 /*
2 * kernel/heap.c
3 * Copyright (C) 1996, Onno Hovers, All rights reserved
4 *
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.
9 *
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.
14 *
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.
19 *
20 * Win32 heap functions (HeapXXX).
21 *
22 */
23
24 /*
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
27 */
28
29 #include <ddk/ntddk.h>
30 #include <ntdll/rtl.h>
31
32 #define NDEBUG
33 #include <kernel32/kernel32.h>
34
35 /*********************************************************************
36 * HeapCreate -- KERNEL32 *
37 *********************************************************************/
38 HANDLE STDCALL HeapCreate(DWORD flags, DWORD minsize, DWORD maxsize)
39 {
40
41 DPRINT("HeapCreate( 0x%lX, 0x%lX, 0x%lX )\n", flags, minsize, maxsize);
42 return(RtlCreateHeap(flags, NULL, maxsize, minsize, NULL, NULL));
43 }
44
45 /*********************************************************************
46 * HeapDestroy -- KERNEL32 *
47 *********************************************************************/
48 BOOL WINAPI HeapDestroy(HANDLE hheap)
49 {
50 return(RtlDestroyHeap(hheap));
51 }
52
53 /*********************************************************************
54 * HeapAlloc -- KERNEL32 *
55 *********************************************************************/
56 LPVOID STDCALL HeapAlloc(HANDLE hheap, DWORD flags, DWORD size)
57 {
58 return(RtlAllocateHeap(hheap, flags, size));
59 }
60
61 /*********************************************************************
62 * HeapReAlloc -- KERNEL32 *
63 *********************************************************************/
64 LPVOID STDCALL HeapReAlloc(HANDLE hheap, DWORD flags, LPVOID ptr, DWORD size)
65 {
66 return(RtlReAllocHeap(hheap, flags, ptr, size));
67 }
68
69 /*********************************************************************
70 * HeapFree -- KERNEL32 *
71 *********************************************************************/
72 WINBOOL STDCALL HeapFree(HANDLE hheap, DWORD flags, LPVOID ptr)
73 {
74 return(RtlFreeHeap(hheap, flags, ptr));
75 }
76
77 /*********************************************************************
78 * GetProcessHeap -- KERNEL32 *
79 *********************************************************************/
80 HANDLE WINAPI GetProcessHeap(VOID)
81 {
82 DPRINT("GetProcessHeap()\n");
83 return(RtlGetProcessHeap());
84 }
85
86 /********************************************************************
87 * GetProcessHeaps -- KERNEL32 *
88 * *
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 )
93 {
94 }
95
96 /*********************************************************************
97 * HeapLock -- KERNEL32 *
98 *********************************************************************/
99 BOOL WINAPI HeapLock(HANDLE hheap)
100 {
101 return(RtlLockHeap(hheap));
102 }
103
104 /*********************************************************************
105 * HeapUnlock -- KERNEL32 *
106 *********************************************************************/
107 BOOL WINAPI HeapUnlock(HANDLE hheap)
108 {
109 return(RtlUnlockHeap(hheap));
110 }
111
112 /*********************************************************************
113 * HeapCompact -- KERNEL32 *
114 * *
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)
119 {
120 return(RtlCompactHeap(hheap, flags));
121 }
122
123 /*********************************************************************
124 * HeapSize -- KERNEL32 *
125 *********************************************************************/
126 DWORD WINAPI HeapSize(HANDLE hheap, DWORD flags, LPCVOID pmem)
127 {
128 return(RtlSizeHeap(hheap, flags, pmem));
129 }
130
131 /*********************************************************************
132 * HeapValidate -- KERNEL32 *
133 * *
134 * NOTE: only implemented in NT *
135 *********************************************************************/
136 BOOL WINAPI HeapValidate(HANDLE hheap, DWORD flags, LPCVOID pmem)
137 {
138 return(RtlValidateHeap(hheap, flags, pmem));
139 }
140