blob: 1ca3b64879e362fc35bc100a1833c529a80515a3 [file] [log] [blame]
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001/*
2 * basic interfaces
3 *
4 * Copyright 1997 Marcus Meissner
5 */
6
7#include <ctype.h>
8#include <stdlib.h>
9#include <string.h>
Alexandre Julliarda11d7b11998-03-01 20:05:02 +000010#include <assert.h>
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000011#include "winerror.h"
Alexandre Julliarda11d7b11998-03-01 20:05:02 +000012#include "ldt.h"
13#include "heap.h"
Marcus Meissner317af321999-02-17 13:51:06 +000014#include "wine/winbase16.h"
Alexandre Julliard638f1691999-01-17 16:32:32 +000015#include "wine/obj_base.h"
Alexandre Julliarda11d7b11998-03-01 20:05:02 +000016#include "local.h"
17#include "module.h"
Alexandre Julliard359f497e1999-07-04 16:02:24 +000018#include "debugtools.h"
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000019
Francois Gouget452db3f1999-02-17 15:57:24 +000020#include "ifs.h"
Alexandre Julliard638f1691999-01-17 16:32:32 +000021
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000022DEFAULT_DEBUG_CHANNEL(relay)
23
François Gougetd604eb11998-12-18 16:00:03 +000024/* --- IUnknown implementation */
25
Francois Gouget452db3f1999-02-17 15:57:24 +000026typedef struct
27{
28 /* IUnknown fields */
29 ICOM_VTABLE(IUnknown)* lpvtbl;
30 DWORD ref;
31} IUnknownImpl;
Matthew Beckerb05264f1998-10-11 14:21:42 +000032
33/******************************************************************************
Matthew Becker75175341998-10-18 14:39:06 +000034 * IUnknown_AddRef [VTABLE:IUNKNOWN.1]
Matthew Beckerb05264f1998-10-11 14:21:42 +000035 */
François Gougetd604eb11998-12-18 16:00:03 +000036static ULONG WINAPI IUnknown_fnAddRef(LPUNKNOWN iface) {
Francois Gouget452db3f1999-02-17 15:57:24 +000037 ICOM_THIS(IUnknownImpl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +000038 TRACE("(%p)->AddRef()\n",This);
Francois Gouget452db3f1999-02-17 15:57:24 +000039 return ++(This->ref);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000040}
Matthew Becker75175341998-10-18 14:39:06 +000041
42/******************************************************************************
43 * IUnknown_Release [VTABLE:IUNKNOWN.2]
44 */
François Gougetd604eb11998-12-18 16:00:03 +000045static ULONG WINAPI IUnknown_fnRelease(LPUNKNOWN iface) {
Francois Gouget452db3f1999-02-17 15:57:24 +000046 ICOM_THIS(IUnknownImpl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +000047 TRACE("(%p)->Release()\n",This);
Francois Gouget452db3f1999-02-17 15:57:24 +000048 if (!--(This->ref)) {
49 HeapFree(GetProcessHeap(),0,This);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000050 return 0;
51 }
Francois Gouget452db3f1999-02-17 15:57:24 +000052 return This->ref;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000053}
54
Matthew Becker75175341998-10-18 14:39:06 +000055/******************************************************************************
56 * IUnknown_QueryInterface [VTABLE:IUNKNOWN.0]
57 */
François Gougetd604eb11998-12-18 16:00:03 +000058static HRESULT WINAPI IUnknown_fnQueryInterface(LPUNKNOWN iface,REFIID refiid,LPVOID *obj) {
Francois Gouget452db3f1999-02-17 15:57:24 +000059 ICOM_THIS(IUnknownImpl,iface);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000060 char xrefiid[50];
61
Alexandre Julliarda11d7b11998-03-01 20:05:02 +000062 WINE_StringFromCLSID((LPCLSID)refiid,xrefiid);
Alexandre Julliard359f497e1999-07-04 16:02:24 +000063 TRACE("(%p)->QueryInterface(%s,%p)\n",This,xrefiid,obj);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000064
65 if (!memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown))) {
Francois Gouget452db3f1999-02-17 15:57:24 +000066 *obj = This;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000067 return 0;
68 }
69 return OLE_E_ENUM_NOMORE;
70}
71
Paul Quinn2305f3c1999-05-22 11:41:38 +000072static ICOM_VTABLE(IUnknown) uvt =
73{
74 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
François Gougetd604eb11998-12-18 16:00:03 +000075 IUnknown_fnQueryInterface,
76 IUnknown_fnAddRef,
77 IUnknown_fnRelease
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000078};
79
Matthew Becker75175341998-10-18 14:39:06 +000080/******************************************************************************
81 * IUnknown_Constructor [INTERNAL]
82 */
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000083LPUNKNOWN
84IUnknown_Constructor() {
Francois Gouget452db3f1999-02-17 15:57:24 +000085 IUnknownImpl* unk;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000086
Francois Gouget452db3f1999-02-17 15:57:24 +000087 unk = (IUnknownImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IUnknownImpl));
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000088 unk->lpvtbl = &uvt;
89 unk->ref = 1;
François Gougetd604eb11998-12-18 16:00:03 +000090 return (LPUNKNOWN)unk;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000091}
92
Matthew Beckerb05264f1998-10-11 14:21:42 +000093
Alexandre Julliard638f1691999-01-17 16:32:32 +000094/* --- IMalloc16 implementation */
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000095
Alexandre Julliard638f1691999-01-17 16:32:32 +000096
Francois Gouget452db3f1999-02-17 15:57:24 +000097typedef struct
98{
Alexandre Julliard638f1691999-01-17 16:32:32 +000099 /* IUnknown fields */
100 ICOM_VTABLE(IMalloc16)* lpvtbl;
101 DWORD ref;
102 /* IMalloc16 fields */
103 /* Gmm, I think one is not enough, we should probably manage a list of
104 * heaps
Matthew Beckerb05264f1998-10-11 14:21:42 +0000105 */
Alexandre Julliard638f1691999-01-17 16:32:32 +0000106 HGLOBAL16 heap;
Francois Gouget452db3f1999-02-17 15:57:24 +0000107} IMalloc16Impl;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000108
Matthew Beckerb05264f1998-10-11 14:21:42 +0000109/******************************************************************************
110 * IMalloc16_QueryInterface [COMPOBJ.500]
111 */
Francois Gouget93217c61999-02-10 06:42:03 +0000112HRESULT WINAPI IMalloc16_fnQueryInterface(IMalloc16* iface,REFIID refiid,LPVOID *obj) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000113 ICOM_THIS(IMalloc16Impl,iface);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000114 char xrefiid[50];
115
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000116 WINE_StringFromCLSID((LPCLSID)refiid,xrefiid);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000117 TRACE("(%p)->QueryInterface(%s,%p)\n",This,xrefiid,obj);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000118 if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
119 !memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc))
120 ) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000121 *obj = This;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000122 return 0;
123 }
124 return OLE_E_ENUM_NOMORE;
125}
126
Matthew Becker75175341998-10-18 14:39:06 +0000127/******************************************************************************
Alexandre Julliard638f1691999-01-17 16:32:32 +0000128 * IMalloc16_AddRef [COMPOBJ.501]
129 */
Francois Gouget93217c61999-02-10 06:42:03 +0000130ULONG WINAPI IMalloc16_fnAddRef(IMalloc16* iface) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000131 ICOM_THIS(IMalloc16Impl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000132 TRACE("(%p)->AddRef()\n",This);
Alexandre Julliard638f1691999-01-17 16:32:32 +0000133 return 1; /* cannot be freed */
134}
135
136/******************************************************************************
137 * IMalloc16_Release [COMPOBJ.502]
138 */
Francois Gouget93217c61999-02-10 06:42:03 +0000139ULONG WINAPI IMalloc16_fnRelease(IMalloc16* iface) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000140 ICOM_THIS(IMalloc16Impl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000141 TRACE("(%p)->Release()\n",This);
Alexandre Julliard638f1691999-01-17 16:32:32 +0000142 return 1; /* cannot be freed */
143}
144
145/******************************************************************************
Matthew Becker75175341998-10-18 14:39:06 +0000146 * IMalloc16_Alloc [COMPOBJ.503]
147 */
Alexandre Julliard638f1691999-01-17 16:32:32 +0000148LPVOID WINAPI IMalloc16_fnAlloc(IMalloc16* iface,DWORD cb) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000149 ICOM_THIS(IMalloc16Impl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000150 TRACE("(%p)->Alloc(%ld)\n",This,cb);
Francois Gouget452db3f1999-02-17 15:57:24 +0000151 return (LPVOID)PTR_SEG_OFF_TO_SEGPTR(This->heap,LOCAL_Alloc(This->heap,0,cb));
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000152}
153
Matthew Becker75175341998-10-18 14:39:06 +0000154/******************************************************************************
155 * IMalloc16_Realloc [COMPOBJ.504]
156 */
Alexandre Julliard638f1691999-01-17 16:32:32 +0000157LPVOID WINAPI IMalloc16_fnRealloc(IMalloc16* iface,LPVOID pv,DWORD cb) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000158 ICOM_THIS(IMalloc16Impl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000159 TRACE("(%p)->Realloc(%p,%ld)\n",This,pv,cb);
Francois Gouget452db3f1999-02-17 15:57:24 +0000160 return (LPVOID)PTR_SEG_OFF_TO_SEGPTR(This->heap,LOCAL_ReAlloc(This->heap,0,LOWORD(pv),cb));
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000161}
Matthew Becker75175341998-10-18 14:39:06 +0000162
163/******************************************************************************
164 * IMalloc16_Free [COMPOBJ.505]
165 */
Alexandre Julliard638f1691999-01-17 16:32:32 +0000166VOID WINAPI IMalloc16_fnFree(IMalloc16* iface,LPVOID pv) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000167 ICOM_THIS(IMalloc16Impl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000168 TRACE("(%p)->Free(%p)\n",This,pv);
Francois Gouget452db3f1999-02-17 15:57:24 +0000169 LOCAL_Free(This->heap,LOWORD(pv));
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000170}
171
Matthew Becker75175341998-10-18 14:39:06 +0000172/******************************************************************************
173 * IMalloc16_GetSize [COMPOBJ.506]
174 */
Alexandre Julliard638f1691999-01-17 16:32:32 +0000175DWORD WINAPI IMalloc16_fnGetSize(const IMalloc16* iface,LPVOID pv) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000176 ICOM_CTHIS(IMalloc16Impl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000177 TRACE("(%p)->GetSize(%p)\n",This,pv);
Francois Gouget452db3f1999-02-17 15:57:24 +0000178 return LOCAL_Size(This->heap,LOWORD(pv));
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000179}
180
Matthew Becker75175341998-10-18 14:39:06 +0000181/******************************************************************************
182 * IMalloc16_DidAlloc [COMPOBJ.507]
183 */
Alexandre Julliard638f1691999-01-17 16:32:32 +0000184INT16 WINAPI IMalloc16_fnDidAlloc(const IMalloc16* iface,LPVOID pv) {
185 ICOM_CTHIS(IMalloc16,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000186 TRACE("(%p)->DidAlloc(%p)\n",This,pv);
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000187 return (INT16)-1;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000188}
Matthew Becker75175341998-10-18 14:39:06 +0000189
190/******************************************************************************
191 * IMalloc16_HeapMinimize [COMPOBJ.508]
192 */
Alexandre Julliard638f1691999-01-17 16:32:32 +0000193LPVOID WINAPI IMalloc16_fnHeapMinimize(IMalloc16* iface) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000194 ICOM_THIS(IMalloc16Impl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000195 TRACE("(%p)->HeapMinimize()\n",This);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000196 return NULL;
197}
198
Alexandre Julliard638f1691999-01-17 16:32:32 +0000199static ICOM_VTABLE(IMalloc16)* msegvt16 = NULL;
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000200
Matthew Becker75175341998-10-18 14:39:06 +0000201/******************************************************************************
202 * IMalloc16_Constructor [VTABLE]
203 */
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000204LPMALLOC16
205IMalloc16_Constructor() {
Francois Gouget452db3f1999-02-17 15:57:24 +0000206 IMalloc16Impl* This;
Alexandre Julliard46ea8b31998-05-03 19:01:20 +0000207 HMODULE16 hcomp = GetModuleHandle16("COMPOBJ");
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000208
Francois Gouget452db3f1999-02-17 15:57:24 +0000209 This = (IMalloc16Impl*)SEGPTR_NEW(IMalloc16Impl);
Alexandre Julliard46ea8b31998-05-03 19:01:20 +0000210 if (!msegvt16) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000211 This->lpvtbl = msegvt16 = SEGPTR_NEW(ICOM_VTABLE(IMalloc16));
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000212
Francois Gouget93217c61999-02-10 06:42:03 +0000213#define VTENT(x) msegvt16->fn##x = (void*)WIN32_GetProcAddress16(hcomp,"IMalloc16_"#x);assert(msegvt16->fn##x)
Alexandre Julliard638f1691999-01-17 16:32:32 +0000214 VTENT(QueryInterface);
215 VTENT(AddRef);
216 VTENT(Release);
Alexandre Julliard638f1691999-01-17 16:32:32 +0000217 VTENT(Alloc);
218 VTENT(Realloc);
219 VTENT(Free);
220 VTENT(GetSize);
221 VTENT(DidAlloc);
222 VTENT(HeapMinimize);
223 msegvt16 = (ICOM_VTABLE(IMalloc16)*)SEGPTR_GET(msegvt16);
224#undef VTENT
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000225 }
Francois Gouget452db3f1999-02-17 15:57:24 +0000226 This->ref = 1;
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000227 /* FIXME: implement multiple heaps */
Francois Gouget452db3f1999-02-17 15:57:24 +0000228 This->heap = GlobalAlloc16(GMEM_MOVEABLE,64000);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000229 LocalInit16(This->heap,0,64000);
Francois Gouget452db3f1999-02-17 15:57:24 +0000230 return (LPMALLOC16)SEGPTR_GET(This);
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000231}
232
Matthew Beckerb05264f1998-10-11 14:21:42 +0000233
Alexandre Julliard638f1691999-01-17 16:32:32 +0000234/* --- IMalloc32 implementation */
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000235
Francois Gouget452db3f1999-02-17 15:57:24 +0000236typedef struct
237{
Alexandre Julliard638f1691999-01-17 16:32:32 +0000238 /* IUnknown fields */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000239 ICOM_VTABLE(IMalloc)* lpvtbl;
Alexandre Julliard638f1691999-01-17 16:32:32 +0000240 DWORD ref;
Francois Gouget452db3f1999-02-17 15:57:24 +0000241} IMalloc32Impl;
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000242
Matthew Beckerb05264f1998-10-11 14:21:42 +0000243/******************************************************************************
Matthew Becker75175341998-10-18 14:39:06 +0000244 * IMalloc32_QueryInterface [VTABLE]
Matthew Beckerb05264f1998-10-11 14:21:42 +0000245 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000246static HRESULT WINAPI IMalloc_fnQueryInterface(LPMALLOC iface,REFIID refiid,LPVOID *obj) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000247 ICOM_THIS(IMalloc32Impl,iface);
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000248 char xrefiid[50];
249
250 WINE_StringFromCLSID((LPCLSID)refiid,xrefiid);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000251 TRACE("(%p)->QueryInterface(%s,%p)\n",This,xrefiid,obj);
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000252 if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
253 !memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc))
254 ) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000255 *obj = This;
Alexandre Julliard638f1691999-01-17 16:32:32 +0000256 return S_OK;
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000257 }
258 return OLE_E_ENUM_NOMORE;
259}
260
Matthew Becker75175341998-10-18 14:39:06 +0000261/******************************************************************************
Alexandre Julliard638f1691999-01-17 16:32:32 +0000262 * IMalloc32_AddRef [VTABLE]
263 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000264static ULONG WINAPI IMalloc_fnAddRef(LPMALLOC iface) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000265 ICOM_THIS(IMalloc32Impl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000266 TRACE("(%p)->AddRef()\n",This);
Alexandre Julliard638f1691999-01-17 16:32:32 +0000267 return 1; /* cannot be freed */
268}
269
270/******************************************************************************
271 * IMalloc32_Release [VTABLE]
272 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000273static ULONG WINAPI IMalloc_fnRelease(LPMALLOC iface) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000274 ICOM_THIS(IMalloc32Impl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000275 TRACE("(%p)->Release()\n",This);
Alexandre Julliard638f1691999-01-17 16:32:32 +0000276 return 1; /* cannot be freed */
277}
278
279/******************************************************************************
Matthew Becker75175341998-10-18 14:39:06 +0000280 * IMalloc32_Alloc [VTABLE]
281 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000282static LPVOID WINAPI IMalloc_fnAlloc(LPMALLOC iface,DWORD cb) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000283 ICOM_THIS(IMalloc32Impl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000284 TRACE("(%p)->Alloc(%ld)\n",This,cb);
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000285 return HeapAlloc(GetProcessHeap(),0,cb);
286}
287
Matthew Becker75175341998-10-18 14:39:06 +0000288/******************************************************************************
289 * IMalloc32_Realloc [VTABLE]
290 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000291static LPVOID WINAPI IMalloc_fnRealloc(LPMALLOC iface,LPVOID pv,DWORD cb) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000292 ICOM_THIS(IMalloc32Impl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000293 TRACE("(%p)->Realloc(%p,%ld)\n",This,pv,cb);
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000294 return HeapReAlloc(GetProcessHeap(),0,pv,cb);
295}
Matthew Becker75175341998-10-18 14:39:06 +0000296
297/******************************************************************************
298 * IMalloc32_Free [VTABLE]
299 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000300static VOID WINAPI IMalloc_fnFree(LPMALLOC iface,LPVOID pv) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000301 ICOM_THIS(IMalloc32Impl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000302 TRACE("(%p)->Free(%p)\n",This,pv);
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000303 HeapFree(GetProcessHeap(),0,pv);
304}
305
Matthew Becker75175341998-10-18 14:39:06 +0000306/******************************************************************************
307 * IMalloc32_GetSize [VTABLE]
308 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000309static DWORD WINAPI IMalloc_fnGetSize(const IMalloc* iface,LPVOID pv) {
310 ICOM_CTHIS(IMalloc,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000311 TRACE("(%p)->GetSize(%p)\n",This,pv);
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000312 return HeapSize(GetProcessHeap(),0,pv);
313}
314
Matthew Becker75175341998-10-18 14:39:06 +0000315/******************************************************************************
316 * IMalloc32_DidAlloc [VTABLE]
317 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000318static INT WINAPI IMalloc_fnDidAlloc(const IMalloc* iface,LPVOID pv) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000319 ICOM_CTHIS(IMalloc32Impl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000320 TRACE("(%p)->DidAlloc(%p)\n",This,pv);
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000321 return -1;
322}
Matthew Becker75175341998-10-18 14:39:06 +0000323
324/******************************************************************************
325 * IMalloc32_HeapMinimize [VTABLE]
326 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000327static LPVOID WINAPI IMalloc_fnHeapMinimize(LPMALLOC iface) {
Francois Gouget452db3f1999-02-17 15:57:24 +0000328 ICOM_THIS(IMalloc32Impl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000329 TRACE("(%p)->HeapMinimize()\n",This);
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000330 return NULL;
331}
332
Paul Quinn2305f3c1999-05-22 11:41:38 +0000333static ICOM_VTABLE(IMalloc) VT_IMalloc32 =
334{
335 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
Alexandre Julliarda3960291999-02-26 11:11:13 +0000336 IMalloc_fnQueryInterface,
337 IMalloc_fnAddRef,
338 IMalloc_fnRelease,
339 IMalloc_fnAlloc,
340 IMalloc_fnRealloc,
341 IMalloc_fnFree,
342 IMalloc_fnGetSize,
343 IMalloc_fnDidAlloc,
344 IMalloc_fnHeapMinimize
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000345};
346
Matthew Becker75175341998-10-18 14:39:06 +0000347/******************************************************************************
348 * IMalloc32_Constructor [VTABLE]
349 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000350LPMALLOC
351IMalloc_Constructor() {
Francois Gouget452db3f1999-02-17 15:57:24 +0000352 IMalloc32Impl* This;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000353
Francois Gouget452db3f1999-02-17 15:57:24 +0000354 This = (IMalloc32Impl*)HeapAlloc(GetProcessHeap(),0,sizeof(IMalloc32Impl));
355 This->lpvtbl = &VT_IMalloc32;
356 This->ref = 1;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000357 return (LPMALLOC)This;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000358}
Matthew Beckerb05264f1998-10-11 14:21:42 +0000359
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000360/****************************************************************************
361 * API Functions
362 */
Matthew Beckerb05264f1998-10-11 14:21:42 +0000363
364/******************************************************************************
365 * IsValidInterface32 [OLE32.78]
366 *
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000367 * RETURNS
368 * True, if the passed pointer is a valid interface
369 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000370BOOL WINAPI IsValidInterface(
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000371 LPUNKNOWN punk /* [in] interface to be tested */
372) {
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000373 return !(
Alexandre Julliarda3960291999-02-26 11:11:13 +0000374 IsBadReadPtr(punk,4) ||
375 IsBadReadPtr(punk->lpvtbl,4) ||
376 IsBadReadPtr(punk->lpvtbl->fnQueryInterface,9) ||
377 IsBadCodePtr(punk->lpvtbl->fnQueryInterface)
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000378 );
379}