~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/mapi32/imalloc.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * MAPI Default IMalloc implementation
  3  *
  4  * Copyright 2004 Jon Griffiths
  5  *
  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.
 10  *
 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.
 15  *
 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
 19  */
 20 
 21 #include <stdarg.h>
 22 
 23 #define COBJMACROS
 24 #define NONAMELESSUNION
 25 #define NONAMELESSSTRUCT
 26 #include "windef.h"
 27 #include "winbase.h"
 28 #include "winreg.h"
 29 #include "winuser.h"
 30 #include "winerror.h"
 31 #include "winternl.h"
 32 #include "objbase.h"
 33 #include "shlwapi.h"
 34 #include "mapiutil.h"
 35 #include "util.h"
 36 #include "wine/debug.h"
 37 
 38 WINE_DEFAULT_DEBUG_CHANNEL(mapi);
 39 
 40 static const IMallocVtbl MAPI_IMalloc_vt;
 41 
 42 typedef struct
 43 {
 44   const IMallocVtbl *lpVtbl;
 45   LONG lRef;
 46 } MAPI_IMALLOC;
 47 
 48 static MAPI_IMALLOC MAPI_IMalloc = { &MAPI_IMalloc_vt, 0u };
 49 
 50 extern LONG MAPI_ObjectCount; /* In mapi32_main.c */
 51 
 52 /*************************************************************************
 53  * MAPIGetDefaultMalloc@0 (MAPI32.59)
 54  *
 55  * Get the default MAPI IMalloc interface.
 56  *
 57  * PARAMS
 58  *  None.
 59  *
 60  * RETURNS
 61  *  A pointer to the MAPI default allocator.
 62  */
 63 LPMALLOC WINAPI MAPIGetDefaultMalloc(void)
 64 {
 65     TRACE("()\n");
 66 
 67     if (mapiFunctions.MAPIGetDefaultMalloc)
 68         return mapiFunctions.MAPIGetDefaultMalloc();
 69 
 70     IMalloc_AddRef((LPMALLOC)&MAPI_IMalloc);
 71     return (LPMALLOC)&MAPI_IMalloc;
 72 }
 73 
 74 /**************************************************************************
 75  * IMAPIMalloc_QueryInterface
 76  */
 77 static HRESULT WINAPI IMAPIMalloc_fnQueryInterface(LPMALLOC iface, REFIID refiid,
 78                                                    LPVOID *ppvObj)
 79 {
 80     TRACE("(%s,%p)\n", debugstr_guid(refiid), ppvObj);
 81 
 82     if (IsEqualIID(refiid, &IID_IUnknown) ||
 83         IsEqualIID(refiid, &IID_IMalloc))
 84     {
 85         *ppvObj = &MAPI_IMalloc;
 86         TRACE("Returning IMalloc (%p)\n", *ppvObj);
 87         return S_OK;
 88     }
 89     TRACE("Returning E_NOINTERFACE\n");
 90     return E_NOINTERFACE;
 91 }
 92 
 93 /**************************************************************************
 94  * IMAPIMalloc_AddRef
 95  */
 96 static ULONG WINAPI IMAPIMalloc_fnAddRef(LPMALLOC iface)
 97 {
 98     TRACE("(%p)\n", iface);
 99     InterlockedIncrement(&MAPI_ObjectCount);
100     return 1u;
101 }
102 
103 /**************************************************************************
104  * IMAPIMalloc_Release
105  */
106 static ULONG WINAPI IMAPIMalloc_fnRelease(LPMALLOC iface)
107 {
108     TRACE("(%p)\n", iface);
109     InterlockedDecrement(&MAPI_ObjectCount);
110     return 1u;
111 }
112 
113 /**************************************************************************
114  * IMAPIMalloc_Alloc
115  */
116 static LPVOID WINAPI IMAPIMalloc_fnAlloc(LPMALLOC iface, DWORD cb)
117 {
118     TRACE("(%p)->(%d)\n", iface, cb);
119 
120     return LocalAlloc(LMEM_FIXED, cb);
121 }
122 
123 /**************************************************************************
124  * IMAPIMalloc_Realloc
125  */
126 static LPVOID WINAPI IMAPIMalloc_fnRealloc(LPMALLOC iface, LPVOID pv, DWORD cb)
127 {
128     TRACE("(%p)->(%p, %d)\n", iface, pv, cb);
129 
130     if (!pv)
131         return LocalAlloc(LMEM_FIXED, cb);
132 
133     if (cb)
134         return LocalReAlloc(pv, cb, LMEM_MOVEABLE);
135 
136     LocalFree(pv);
137     return NULL;
138 }
139 
140 /**************************************************************************
141  * IMAPIMalloc_Free
142  */
143 static void WINAPI IMAPIMalloc_fnFree(LPMALLOC iface, LPVOID pv)
144 {
145     TRACE("(%p)->(%p)\n", iface, pv);
146     LocalFree(pv);
147 }
148 
149 /**************************************************************************
150  * IMAPIMalloc_GetSize
151  */
152 static DWORD WINAPI IMAPIMalloc_fnGetSize(LPMALLOC iface, LPVOID pv)
153 {
154     TRACE("(%p)->(%p)\n", iface, pv);
155     return LocalSize(pv);
156 }
157 
158 /**************************************************************************
159  * IMAPIMalloc_DidAlloc
160  */
161 static INT WINAPI IMAPIMalloc_fnDidAlloc(LPMALLOC iface, LPVOID pv)
162 {
163     TRACE("(%p)->(%p)\n", iface, pv);
164     return -1;
165 }
166 
167 /**************************************************************************
168  * IMAPIMalloc_HeapMinimize
169  */
170 static void WINAPI IMAPIMalloc_fnHeapMinimize(LPMALLOC iface)
171 {
172     TRACE("(%p)\n", iface);
173 }
174 
175 static const IMallocVtbl MAPI_IMalloc_vt =
176 {
177     IMAPIMalloc_fnQueryInterface,
178     IMAPIMalloc_fnAddRef,
179     IMAPIMalloc_fnRelease,
180     IMAPIMalloc_fnAlloc,
181     IMAPIMalloc_fnRealloc,
182     IMAPIMalloc_fnFree,
183     IMAPIMalloc_fnGetSize,
184     IMAPIMalloc_fnDidAlloc,
185     IMAPIMalloc_fnHeapMinimize
186 };
187 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.