wordpad: Add a dropdown menu to the bullet button.
[wine.git] / dlls / mapi32 / imalloc.c
blob3e95a6c7cd372d539974de33a85a1ce9fd4182ec
1 /*
2 * MAPI Default IMalloc implementation
4 * Copyright 2004 Jon Griffiths
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winreg.h"
28 #include "winuser.h"
29 #include "winerror.h"
30 #include "winternl.h"
31 #include "objbase.h"
32 #include "shlwapi.h"
33 #include "mapiutil.h"
34 #include "util.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mapi);
39 static const IMallocVtbl MAPI_IMalloc_vt;
41 typedef struct
43 IMalloc IMalloc_iface;
44 LONG lRef;
45 } MAPI_IMALLOC;
47 static MAPI_IMALLOC MAPI_IMalloc = { { &MAPI_IMalloc_vt }, 0 };
49 extern LONG MAPI_ObjectCount; /* In mapi32_main.c */
51 /*************************************************************************
52 * MAPIGetDefaultMalloc@0 (MAPI32.59)
54 * Get the default MAPI IMalloc interface.
56 * PARAMS
57 * None.
59 * RETURNS
60 * A pointer to the MAPI default allocator.
62 LPMALLOC WINAPI MAPIGetDefaultMalloc(void)
64 TRACE("()\n");
66 if (mapiFunctions.MAPIGetDefaultMalloc)
67 return mapiFunctions.MAPIGetDefaultMalloc();
69 IMalloc_AddRef(&MAPI_IMalloc.IMalloc_iface);
70 return &MAPI_IMalloc.IMalloc_iface;
73 /**************************************************************************
74 * IMAPIMalloc_QueryInterface
76 static HRESULT WINAPI IMAPIMalloc_fnQueryInterface(LPMALLOC iface, REFIID refiid,
77 LPVOID *ppvObj)
79 TRACE("(%s,%p)\n", debugstr_guid(refiid), ppvObj);
81 if (IsEqualIID(refiid, &IID_IUnknown) ||
82 IsEqualIID(refiid, &IID_IMalloc))
84 *ppvObj = &MAPI_IMalloc;
85 TRACE("Returning IMalloc (%p)\n", *ppvObj);
86 return S_OK;
88 TRACE("Returning E_NOINTERFACE\n");
89 return E_NOINTERFACE;
92 /**************************************************************************
93 * IMAPIMalloc_AddRef
95 static ULONG WINAPI IMAPIMalloc_fnAddRef(LPMALLOC iface)
97 TRACE("(%p)\n", iface);
98 InterlockedIncrement(&MAPI_ObjectCount);
99 return 1u;
102 /**************************************************************************
103 * IMAPIMalloc_Release
105 static ULONG WINAPI IMAPIMalloc_fnRelease(LPMALLOC iface)
107 TRACE("(%p)\n", iface);
108 InterlockedDecrement(&MAPI_ObjectCount);
109 return 1u;
112 /**************************************************************************
113 * IMAPIMalloc_Alloc
115 static LPVOID WINAPI IMAPIMalloc_fnAlloc(LPMALLOC iface, SIZE_T cb)
117 TRACE("(%p)->(%ld)\n", iface, cb);
119 return LocalAlloc(LMEM_FIXED, cb);
122 /**************************************************************************
123 * IMAPIMalloc_Realloc
125 static LPVOID WINAPI IMAPIMalloc_fnRealloc(LPMALLOC iface, LPVOID pv, SIZE_T cb)
127 TRACE("(%p)->(%p, %ld)\n", iface, pv, cb);
129 if (!pv)
130 return LocalAlloc(LMEM_FIXED, cb);
132 if (cb)
133 return LocalReAlloc(pv, cb, LMEM_MOVEABLE);
135 LocalFree(pv);
136 return NULL;
139 /**************************************************************************
140 * IMAPIMalloc_Free
142 static void WINAPI IMAPIMalloc_fnFree(LPMALLOC iface, LPVOID pv)
144 TRACE("(%p)->(%p)\n", iface, pv);
145 LocalFree(pv);
148 /**************************************************************************
149 * IMAPIMalloc_GetSize
151 static SIZE_T WINAPI IMAPIMalloc_fnGetSize(LPMALLOC iface, LPVOID pv)
153 TRACE("(%p)->(%p)\n", iface, pv);
154 return LocalSize(pv);
157 /**************************************************************************
158 * IMAPIMalloc_DidAlloc
160 static INT WINAPI IMAPIMalloc_fnDidAlloc(LPMALLOC iface, LPVOID pv)
162 TRACE("(%p)->(%p)\n", iface, pv);
163 return -1;
166 /**************************************************************************
167 * IMAPIMalloc_HeapMinimize
169 static void WINAPI IMAPIMalloc_fnHeapMinimize(LPMALLOC iface)
171 TRACE("(%p)\n", iface);
174 static const IMallocVtbl MAPI_IMalloc_vt =
176 IMAPIMalloc_fnQueryInterface,
177 IMAPIMalloc_fnAddRef,
178 IMAPIMalloc_fnRelease,
179 IMAPIMalloc_fnAlloc,
180 IMAPIMalloc_fnRealloc,
181 IMAPIMalloc_fnFree,
182 IMAPIMalloc_fnGetSize,
183 IMAPIMalloc_fnDidAlloc,
184 IMAPIMalloc_fnHeapMinimize