32-bit clipboard support.
[wine/multimedia.git] / include / heap.h
blob84f6dc25a37ae23292cf8ccb2a521f4b327c779b
1 /*
2 * Win32 heap definitions
4 * Copyright 1996 Alexandre Julliard
5 */
7 #ifndef __WINE_HEAP_H
8 #define __WINE_HEAP_H
10 #include "winbase.h"
11 #include "winnt.h"
13 extern HANDLE32 SystemHeap;
14 extern HANDLE32 SegptrHeap;
15 extern CRITICAL_SECTION *HEAP_SystemLock;
17 extern int HEAP_IsInsideHeap( HANDLE32 heap, DWORD flags, LPCVOID ptr );
18 extern SEGPTR HEAP_GetSegptr( HANDLE32 heap, DWORD flags, LPCVOID ptr );
19 extern LPVOID HEAP_xalloc( HANDLE32 heap, DWORD flags, DWORD size );
20 extern LPSTR HEAP_strdupA( HANDLE32 heap, DWORD flags, LPCSTR str );
21 extern LPWSTR HEAP_strdupW( HANDLE32 heap, DWORD flags, LPCWSTR str );
22 extern LPWSTR HEAP_strdupAtoW( HANDLE32 heap, DWORD flags, LPCSTR str );
23 extern LPSTR HEAP_strdupWtoA( HANDLE32 heap, DWORD flags, LPCWSTR str );
25 /* SEGPTR helper macros */
27 #define SEGPTR_ALLOC(size) \
28 (HeapAlloc( SegptrHeap, 0, (size) ))
29 #define SEGPTR_NEW(type) \
30 ((type *)HeapAlloc( SegptrHeap, 0, sizeof(type) ))
31 #define SEGPTR_STRDUP(str) \
32 (HIWORD(str) ? HEAP_strdupA( SegptrHeap, 0, (str) ) : (LPSTR)(str))
33 #define SEGPTR_STRDUP_WtoA(str) \
34 (HIWORD(str) ? HEAP_strdupWtoA( SegptrHeap, 0, (str) ) : (LPSTR)(str))
35 /* define an inline function, a macro won't do */
36 static __inline__ SEGPTR SEGPTR_Get(LPCVOID ptr) {
37 return (HIWORD(ptr) ? HEAP_GetSegptr( SegptrHeap, 0, ptr ) : (SEGPTR)ptr);
39 #define SEGPTR_GET(ptr) SEGPTR_Get(ptr)
40 #define SEGPTR_FREE(ptr) \
41 (HIWORD(ptr) ? HeapFree( SegptrHeap, 0, (ptr) ) : 0)
43 /* System heap locking macros */
45 #define SYSTEM_LOCK() (EnterCriticalSection(HEAP_SystemLock))
46 #define SYSTEM_UNLOCK() (LeaveCriticalSection(HEAP_SystemLock))
47 /* Use this one only when you own the lock! */
48 #define SYSTEM_LOCK_COUNT() (HEAP_SystemLock->RecursionCount)
51 typedef struct
53 LPVOID lpData;
54 DWORD cbData;
55 BYTE cbOverhead;
56 BYTE iRegionIndex;
57 WORD wFlags;
58 union {
59 struct {
60 HANDLE32 hMem;
61 DWORD dwReserved[3];
62 } Block;
63 struct {
64 DWORD dwCommittedSize;
65 DWORD dwUnCommittedSize;
66 LPVOID lpFirstBlock;
67 LPVOID lpLastBlock;
68 } Region;
69 } Foo;
70 } PROCESS_HEAP_ENTRY, *LPPROCESS_HEAP_ENTRY;
72 #endif /* __WINE_HEAP_H */