Fixed a couple of HWND type mismatches.
[wine/multimedia.git] / include / heap.h
blob112eecb21b159e3f702e8f55f43ca10c14407449
1 /*
2 * Win32 heap definitions
4 * Copyright 1996 Alexandre Julliard
5 */
7 #ifndef __WINE_HEAP_H
8 #define __WINE_HEAP_H
10 #include "config.h"
12 #include <string.h>
13 #include "winbase.h"
14 #include "winnls.h"
15 #include "wine/unicode.h"
16 #include "wine/windef16.h" /* for SEGPTR */
18 extern SEGPTR HEAP_GetSegptr( HANDLE heap, DWORD flags, LPCVOID ptr );
20 /* SEGPTR helper macros */
22 #define SEGPTR_ALLOC(size) \
23 (HeapAlloc( GetProcessHeap(), HEAP_WINE_SEGPTR, (size) ))
24 #define SEGPTR_NEW(type) \
25 ((type *)HeapAlloc( GetProcessHeap(), HEAP_WINE_SEGPTR, sizeof(type) ))
26 #define SEGPTR_STRDUP_WtoA(str) \
27 (HIWORD(str) ? HEAP_strdupWtoA( GetProcessHeap(), HEAP_WINE_SEGPTR, (str) ) : (LPSTR)(str))
28 #define SEGPTR_FREE(ptr) \
29 (HIWORD(ptr) ? HeapFree( GetProcessHeap(), HEAP_WINE_SEGPTR, (ptr) ) : 0)
30 #define SEGPTR_GET(ptr) MapLS(ptr)
32 inline static LPSTR SEGPTR_STRDUP( LPCSTR str )
34 if (HIWORD(str))
36 INT len = strlen(str) + 1;
37 LPSTR p = HeapAlloc( GetProcessHeap(), HEAP_WINE_SEGPTR, len );
38 if (p) memcpy( p, str, len );
39 return p;
41 return (LPSTR)str;
44 /* strdup macros */
45 /* DO NOT USE THEM!! they will go away soon */
47 inline static LPWSTR HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str )
49 LPWSTR ret;
50 INT len;
52 if (!str) return NULL;
53 len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
54 ret = HeapAlloc( heap, flags, len * sizeof(WCHAR) );
55 if (ret) MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
56 return ret;
59 inline static LPSTR HEAP_strdupWtoA( HANDLE heap, DWORD flags, LPCWSTR str )
61 LPSTR ret;
62 INT len;
64 if (!str) return NULL;
65 len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
66 ret = HeapAlloc( heap, flags, len );
67 if(ret) WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
68 return ret;
71 #endif /* __WINE_HEAP_H */