Commit c2f6d059 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

compobj.dll16: COM cleanup for the IMalloc16 iface.

parent 4156a804
......@@ -88,17 +88,20 @@ static LPMALLOC16 currentMalloc16=NULL;
typedef struct
{
/* IUnknown fields */
const IMalloc16Vtbl *lpVtbl;
DWORD ref;
/* IMalloc16 fields */
IMalloc16 IMalloc16_iface;
DWORD ref;
} IMalloc16Impl;
static inline IMalloc16Impl *impl_from_IMalloc16(IMalloc16 *iface)
{
return CONTAINING_RECORD(iface, IMalloc16Impl, IMalloc16_iface);
}
/******************************************************************************
* IMalloc16_QueryInterface [COMPOBJ.500]
*/
HRESULT CDECL IMalloc16_fnQueryInterface(IMalloc16* iface,REFIID refiid,LPVOID *obj) {
IMalloc16Impl *This = (IMalloc16Impl *)iface;
IMalloc16Impl *This = impl_from_IMalloc16(iface);
TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
......@@ -114,7 +117,8 @@ HRESULT CDECL IMalloc16_fnQueryInterface(IMalloc16* iface,REFIID refiid,LPVOID *
* IMalloc16_AddRef [COMPOBJ.501]
*/
ULONG CDECL IMalloc16_fnAddRef(IMalloc16* iface) {
IMalloc16Impl *This = (IMalloc16Impl *)iface;
IMalloc16Impl *This = impl_from_IMalloc16(iface);
TRACE("(%p)->AddRef()\n",This);
return 1; /* cannot be freed */
}
......@@ -123,7 +127,8 @@ ULONG CDECL IMalloc16_fnAddRef(IMalloc16* iface) {
* IMalloc16_Release [COMPOBJ.502]
*/
ULONG CDECL IMalloc16_fnRelease(IMalloc16* iface) {
IMalloc16Impl *This = (IMalloc16Impl *)iface;
IMalloc16Impl *This = impl_from_IMalloc16(iface);
TRACE("(%p)->Release()\n",This);
return 1; /* cannot be freed */
}
......@@ -132,7 +137,8 @@ ULONG CDECL IMalloc16_fnRelease(IMalloc16* iface) {
* IMalloc16_Alloc [COMPOBJ.503]
*/
SEGPTR CDECL IMalloc16_fnAlloc(IMalloc16* iface,DWORD cb) {
IMalloc16Impl *This = (IMalloc16Impl *)iface;
IMalloc16Impl *This = impl_from_IMalloc16(iface);
TRACE("(%p)->Alloc(%d)\n",This,cb);
return MapLS( HeapAlloc( GetProcessHeap(), 0, cb ) );
}
......@@ -143,7 +149,7 @@ SEGPTR CDECL IMalloc16_fnAlloc(IMalloc16* iface,DWORD cb) {
VOID CDECL IMalloc16_fnFree(IMalloc16* iface,SEGPTR pv)
{
void *ptr = MapSL(pv);
IMalloc16Impl *This = (IMalloc16Impl *)iface;
IMalloc16Impl *This = impl_from_IMalloc16(iface);
TRACE("(%p)->Free(%08x)\n",This,pv);
UnMapLS(pv);
HeapFree( GetProcessHeap(), 0, ptr );
......@@ -155,7 +161,8 @@ VOID CDECL IMalloc16_fnFree(IMalloc16* iface,SEGPTR pv)
SEGPTR CDECL IMalloc16_fnRealloc(IMalloc16* iface,SEGPTR pv,DWORD cb)
{
SEGPTR ret;
IMalloc16Impl *This = (IMalloc16Impl *)iface;
IMalloc16Impl *This = impl_from_IMalloc16(iface);
TRACE("(%p)->Realloc(%08x,%d)\n",This,pv,cb);
if (!pv)
ret = IMalloc16_fnAlloc(iface, cb);
......@@ -174,7 +181,8 @@ SEGPTR CDECL IMalloc16_fnRealloc(IMalloc16* iface,SEGPTR pv,DWORD cb)
*/
DWORD CDECL IMalloc16_fnGetSize(IMalloc16* iface,SEGPTR pv)
{
IMalloc16Impl *This = (IMalloc16Impl *)iface;
IMalloc16Impl *This = impl_from_IMalloc16(iface);
TRACE("(%p)->GetSize(%08x)\n",This,pv);
return HeapSize( GetProcessHeap(), 0, MapSL(pv) );
}
......@@ -183,7 +191,8 @@ DWORD CDECL IMalloc16_fnGetSize(IMalloc16* iface,SEGPTR pv)
* IMalloc16_DidAlloc [COMPOBJ.507]
*/
INT16 CDECL IMalloc16_fnDidAlloc(IMalloc16* iface,LPVOID pv) {
IMalloc16 *This = iface;
IMalloc16Impl *This = impl_from_IMalloc16(iface);
TRACE("(%p)->DidAlloc(%p)\n",This,pv);
return (INT16)-1;
}
......@@ -192,7 +201,8 @@ INT16 CDECL IMalloc16_fnDidAlloc(IMalloc16* iface,LPVOID pv) {
* IMalloc16_HeapMinimize [COMPOBJ.508]
*/
LPVOID CDECL IMalloc16_fnHeapMinimize(IMalloc16* iface) {
IMalloc16Impl *This = (IMalloc16Impl *)iface;
IMalloc16Impl *This = impl_from_IMalloc16(iface);
TRACE("(%p)->HeapMinimize()\n",This);
return NULL;
}
......@@ -224,7 +234,7 @@ IMalloc16_Constructor(void)
#undef VTENT
msegvt16 = MapLS( &vt16 );
}
This->lpVtbl = (const IMalloc16Vtbl*)msegvt16;
This->IMalloc16_iface.lpVtbl = (const IMalloc16Vtbl*)msegvt16;
This->ref = 1;
return (LPMALLOC16)MapLS( This );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment