combase: Use CRT memory allocation functions.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2022-05-19 11:30:40 +02:00 committed by Alexandre Julliard
parent 0f9ad11a27
commit 9d1beee6c7
12 changed files with 118 additions and 141 deletions

View File

@ -160,9 +160,9 @@ static HRESULT apartment_add_dll(const WCHAR *library_name, struct opendll **ret
else
{
len = lstrlenW(library_name);
entry = heap_alloc(sizeof(*entry));
entry = malloc(sizeof(*entry));
if (entry)
entry->library_name = heap_alloc((len + 1) * sizeof(WCHAR));
entry->library_name = malloc((len + 1) * sizeof(WCHAR));
if (entry && entry->library_name)
{
memcpy(entry->library_name, library_name, (len + 1)*sizeof(WCHAR));
@ -175,7 +175,7 @@ static HRESULT apartment_add_dll(const WCHAR *library_name, struct opendll **ret
}
else
{
heap_free(entry);
free(entry);
hr = E_OUTOFMEMORY;
FreeLibrary(hLibrary);
}
@ -199,8 +199,8 @@ static void apartment_release_dll(struct opendll *entry, BOOL free_entry)
TRACE("freeing %p\n", entry->library);
FreeLibrary(entry->library);
heap_free(entry->library_name);
heap_free(entry);
free(entry->library_name);
free(entry);
}
}
@ -212,8 +212,8 @@ static void apartment_release_dlls(void)
LIST_FOR_EACH_ENTRY_SAFE(entry, cursor2, &dlls, struct opendll, entry)
{
list_remove(&entry->entry);
heap_free(entry->library_name);
heap_free(entry);
free(entry->library_name);
free(entry);
}
LeaveCriticalSection(&dlls_cs);
DeleteCriticalSection(&dlls_cs);
@ -279,7 +279,7 @@ static ULONG WINAPI local_server_Release(IServiceProvider *iface)
if (!refcount)
{
assert(!local_server->apt);
heap_free(local_server);
free(local_server);
}
return refcount;
@ -324,7 +324,7 @@ HRESULT apartment_get_local_server_stream(struct apartment *apt, IStream **ret)
{
struct local_server *obj;
obj = heap_alloc(sizeof(*obj));
obj = malloc(sizeof(*obj));
if (obj)
{
obj->IServiceProvider_iface.lpVtbl = &local_server_vtbl;
@ -343,7 +343,7 @@ HRESULT apartment_get_local_server_stream(struct apartment *apt, IStream **ret)
if (SUCCEEDED(hr))
apt->local_server = obj;
else
heap_free(obj);
free(obj);
}
else
hr = E_OUTOFMEMORY;
@ -367,7 +367,7 @@ static struct apartment *apartment_construct(DWORD model)
TRACE("creating new apartment, model %ld\n", model);
apt = heap_alloc_zero(sizeof(*apt));
apt = calloc(1, sizeof(*apt));
apt->tid = GetCurrentThreadId();
list_init(&apt->proxies);
@ -429,7 +429,7 @@ void apartment_freeunusedlibraries(struct apartment *apt, DWORD delay)
{
list_remove(&entry->entry);
apartment_release_dll(entry->dll, TRUE);
heap_free(entry);
free(entry);
}
else
{
@ -531,13 +531,13 @@ void apartment_release(struct apartment *apt)
struct apartment_loaded_dll *apartment_loaded_dll = LIST_ENTRY(cursor, struct apartment_loaded_dll, entry);
apartment_release_dll(apartment_loaded_dll->dll, FALSE);
list_remove(cursor);
heap_free(apartment_loaded_dll);
free(apartment_loaded_dll);
}
apt->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&apt->cs);
heap_free(apt);
free(apt);
}
}
@ -796,7 +796,7 @@ static HRESULT apartment_getclassobject(struct apartment *apt, LPCWSTR dllpath,
if (!found)
{
apartment_loaded_dll = heap_alloc(sizeof(*apartment_loaded_dll));
apartment_loaded_dll = malloc(sizeof(*apartment_loaded_dll));
if (!apartment_loaded_dll)
hr = E_OUTOFMEMORY;
if (SUCCEEDED(hr))
@ -805,7 +805,7 @@ static HRESULT apartment_getclassobject(struct apartment *apt, LPCWSTR dllpath,
apartment_loaded_dll->multi_threaded = FALSE;
hr = apartment_add_dll(dllpath, &apartment_loaded_dll->dll);
if (FAILED(hr))
heap_free(apartment_loaded_dll);
free(apartment_loaded_dll);
}
if (SUCCEEDED(hr))
{
@ -1175,7 +1175,7 @@ HRESULT apartment_increment_mta_usage(CO_MTA_USAGE_COOKIE *cookie)
*cookie = NULL;
if (!(mta_cookie = heap_alloc(sizeof(*mta_cookie))))
if (!(mta_cookie = malloc(sizeof(*mta_cookie))))
return E_OUTOFMEMORY;
EnterCriticalSection(&apt_cs);
@ -1208,7 +1208,7 @@ void apartment_decrement_mta_usage(CO_MTA_USAGE_COOKIE cookie)
if (mta_cookie == cur)
{
list_remove(&cur->entry);
heap_free(cur);
free(cur);
apartment_release(mta);
break;
}

View File

@ -32,7 +32,6 @@
#include "combase_private.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
@ -392,7 +391,7 @@ BOOL WINAPI InternalIsProcessInitialized(void)
*/
HRESULT WINAPI InternalTlsAllocData(struct tlsdata **data)
{
if (!(*data = heap_alloc_zero(sizeof(**data))))
if (!(*data = calloc(1, sizeof(**data))))
return E_OUTOFMEMORY;
list_init(&(*data)->spies);
@ -421,13 +420,13 @@ static void com_cleanup_tlsdata(void)
list_remove(&cursor->entry);
if (cursor->spy)
IInitializeSpy_Release(cursor->spy);
heap_free(cursor);
free(cursor);
}
if (tlsdata->context_token)
IObjContext_Release(tlsdata->context_token);
heap_free(tlsdata);
free(tlsdata);
NtCurrentTeb()->ReservedForOle = NULL;
}
@ -478,7 +477,7 @@ static ULONG WINAPI global_options_Release(IGlobalOptions *iface)
TRACE("%p, refcount %ld.\n", iface, refcount);
if (!refcount)
heap_free(options);
free(options);
return refcount;
}
@ -552,7 +551,7 @@ static HRESULT WINAPI global_options_CreateInstance(IClassFactory *iface, IUnkno
if (outer)
return E_INVALIDARG;
if (!(object = heap_alloc(sizeof(*object))))
if (!(object = malloc(sizeof(*object))))
return E_OUTOFMEMORY;
object->IGlobalOptions_iface.lpVtbl = &global_options_vtbl;
object->refcount = 1;
@ -1393,18 +1392,18 @@ static HRESULT clsid_from_string_reg(LPCOLESTR progid, CLSID *clsid)
WCHAR *buf;
memset(clsid, 0, sizeof(*clsid));
buf = heap_alloc((lstrlenW(progid) + 8) * sizeof(WCHAR));
buf = malloc((lstrlenW(progid) + 8) * sizeof(WCHAR));
if (!buf) return E_OUTOFMEMORY;
lstrcpyW(buf, progid);
lstrcatW(buf, L"\\CLSID");
if (open_classes_key(HKEY_CLASSES_ROOT, buf, MAXIMUM_ALLOWED, &xhkey))
{
heap_free(buf);
free(buf);
WARN("couldn't open key for ProgID %s\n", debugstr_w(progid));
return CO_E_CLASSSTRING;
}
heap_free(buf);
free(buf);
if (RegQueryValueW(xhkey, NULL, buf2, &buf2len))
{
@ -1984,7 +1983,7 @@ HRESULT WINAPI CoRegisterInitializeSpy(IInitializeSpy *spy, ULARGE_INTEGER *cook
if (FAILED(hr))
return hr;
entry = heap_alloc(sizeof(*entry));
entry = malloc(sizeof(*entry));
if (!entry)
{
IInitializeSpy_Release(spy);
@ -2032,7 +2031,7 @@ HRESULT WINAPI CoRevokeInitializeSpy(ULARGE_INTEGER cookie)
if (!tlsdata->spies_lock)
{
list_remove(&spy->entry);
heap_free(spy);
free(spy);
}
return S_OK;
}
@ -2245,7 +2244,7 @@ static void com_revoke_all_ps_clsids(void)
LIST_FOR_EACH_ENTRY_SAFE(cur, cur2, &registered_proxystubs, struct registered_ps, entry)
{
list_remove(&cur->entry);
heap_free(cur);
free(cur);
}
LeaveCriticalSection(&cs_registered_ps);
@ -2365,7 +2364,7 @@ HRESULT WINAPI CoRegisterPSClsid(REFIID riid, REFCLSID rclsid)
}
}
cur = heap_alloc(sizeof(*cur));
cur = malloc(sizeof(*cur));
if (!cur)
{
LeaveCriticalSection(&cs_registered_ps);
@ -2448,7 +2447,7 @@ static ULONG WINAPI thread_context_info_Release(IComThreadingInfo *iface)
releasing context while refcount is at 0 destroys it. */
if (!context->refcount)
{
heap_free(context);
free(context);
return 0;
}
@ -2673,7 +2672,7 @@ HRESULT WINAPI CoGetContextToken(ULONG_PTR *token)
{
struct thread_context *context;
context = heap_alloc_zero(sizeof(*context));
context = calloc(1, sizeof(*context));
if (!context)
return E_OUTOFMEMORY;
@ -2768,7 +2767,7 @@ static void unlock_init_spies(struct tlsdata *tlsdata)
{
if (spy->spy) continue;
list_remove(&spy->entry);
heap_free(spy);
free(spy);
}
}
@ -3001,7 +3000,7 @@ HRESULT WINAPI CoRegisterClassObject(REFCLSID rclsid, IUnknown *object, DWORD cl
return CO_E_OBJISREG;
}
newclass = heap_alloc_zero(sizeof(*newclass));
newclass = calloc(1, sizeof(*newclass));
if (!newclass)
{
apartment_release(apt);
@ -3052,7 +3051,7 @@ static void com_revoke_class_object(struct registered_class *entry)
rpc_revoke_local_server(entry->rpcss_cookie);
IUnknown_Release(entry->object);
heap_free(entry);
free(entry);
}
/* Cleans up rpcss registry */

View File

@ -17,7 +17,6 @@
#include "winternl.h"
#include "wine/orpc.h"
#include "wine/heap.h"
#include "wine/list.h"
extern HINSTANCE hProxyDll;

View File

@ -25,27 +25,9 @@
#include "combase_private.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
static WCHAR *heap_strdupW(const WCHAR *str)
{
WCHAR *ret = NULL;
if (str)
{
size_t size;
size = (lstrlenW(str)+1)*sizeof(WCHAR);
ret = heap_alloc(size);
if (ret)
memcpy(ret, str, size);
}
return ret;
}
struct error_info
{
IErrorInfo IErrorInfo_iface;
@ -125,10 +107,10 @@ static ULONG WINAPI errorinfo_Release(IErrorInfo *iface)
if (!refcount)
{
heap_free(error_info->source);
heap_free(error_info->description);
heap_free(error_info->help_file);
heap_free(error_info);
free(error_info->source);
free(error_info->description);
free(error_info->help_file);
free(error_info);
}
return refcount;
@ -241,8 +223,8 @@ static HRESULT WINAPI create_errorinfo_SetSource(ICreateErrorInfo *iface, LPOLES
TRACE("%p, %s.\n", iface, debugstr_w(source));
heap_free(error_info->source);
error_info->source = heap_strdupW(source);
free(error_info->source);
error_info->source = wcsdup(source);
return S_OK;
}
@ -253,8 +235,8 @@ static HRESULT WINAPI create_errorinfo_SetDescription(ICreateErrorInfo *iface, L
TRACE("%p, %s.\n", iface, debugstr_w(description));
heap_free(error_info->description);
error_info->description = heap_strdupW(description);
free(error_info->description);
error_info->description = wcsdup(description);
return S_OK;
}
@ -265,8 +247,8 @@ static HRESULT WINAPI create_errorinfo_SetHelpFile(ICreateErrorInfo *iface, LPOL
TRACE("%p, %s.\n", iface, debugstr_w(helpfile));
heap_free(error_info->help_file);
error_info->help_file = heap_strdupW(helpfile);
free(error_info->help_file);
error_info->help_file = wcsdup(helpfile);
return S_OK;
}
@ -340,7 +322,7 @@ HRESULT WINAPI CreateErrorInfo(ICreateErrorInfo **ret)
if (!ret) return E_INVALIDARG;
if (!(error_info = heap_alloc(sizeof(*error_info))))
if (!(error_info = malloc(sizeof(*error_info))))
return E_OUTOFMEMORY;
error_info->IErrorInfo_iface.lpVtbl = &errorinfo_vtbl;

View File

@ -48,7 +48,7 @@ static void handle_release(struct handle_wrapper *handle)
if (!ref)
{
if (handle->delete_on_release) GlobalFree(handle->hglobal);
HeapFree(GetProcessHeap(), 0, handle);
free(handle);
}
}
@ -56,14 +56,14 @@ static struct handle_wrapper *handle_create(HGLOBAL hglobal, BOOL delete_on_rele
{
struct handle_wrapper *handle;
handle = HeapAlloc(GetProcessHeap(), 0, sizeof(*handle));
handle = malloc(sizeof(*handle));
if (!handle) return NULL;
/* allocate a handle if one is not supplied */
if (!hglobal) hglobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_NODISCARD | GMEM_SHARE, 0);
if (!hglobal)
{
HeapFree(GetProcessHeap(), 0, handle);
free(handle);
return NULL;
}
handle->ref = 1;
@ -92,7 +92,7 @@ static const IStreamVtbl hglobalstreamvtbl;
static struct hglobal_stream *hglobalstream_construct(void)
{
struct hglobal_stream *object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
struct hglobal_stream *object = calloc(1, sizeof(*object));
if (object)
{
@ -134,7 +134,7 @@ static ULONG WINAPI stream_Release(IStream *iface)
if (!ref)
{
handle_release(stream->handle);
HeapFree(GetProcessHeap(), 0, stream);
free(stream);
}
return ref;
@ -422,7 +422,7 @@ HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL delete_on_release, IS
object->handle = handle_create(hGlobal, delete_on_release);
if (!object->handle)
{
HeapFree(GetProcessHeap(), 0, object);
free(object);
return E_OUTOFMEMORY;
}

View File

@ -21,7 +21,6 @@
#include "oleauto.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(olemalloc);

View File

@ -28,7 +28,6 @@
#include "combase_private.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
@ -219,7 +218,7 @@ static ULONG WINAPI ftmarshaler_inner_Release(IUnknown *iface)
TRACE("%p, refcount %lu\n", iface, refcount);
if (!refcount)
heap_free(marshaler);
free(marshaler);
return refcount;
}
@ -421,7 +420,7 @@ HRESULT WINAPI CoCreateFreeThreadedMarshaler(IUnknown *outer, IUnknown **marshal
TRACE("%p, %p\n", outer, marshaler);
object = heap_alloc(sizeof(*object));
object = malloc(sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
@ -1001,9 +1000,9 @@ static HRESULT WINAPI ClientIdentity_QueryMultipleInterfaces(IMultiQI *iface, UL
ULONG nonlocal_mqis = 0;
ULONG i;
ULONG successful_mqis = 0;
IID *iids = HeapAlloc(GetProcessHeap(), 0, cMQIs * sizeof(*iids));
IID *iids = malloc(cMQIs * sizeof(*iids));
/* mapping of RemQueryInterface index to QueryMultipleInterfaces index */
ULONG *mapping = HeapAlloc(GetProcessHeap(), 0, cMQIs * sizeof(*mapping));
ULONG *mapping = malloc(cMQIs * sizeof(*mapping));
TRACE("cMQIs: %ld\n", cMQIs);
@ -1084,8 +1083,8 @@ static HRESULT WINAPI ClientIdentity_QueryMultipleInterfaces(IMultiQI *iface, UL
TRACE("%ld/%ld successfully queried\n", successful_mqis, cMQIs);
HeapFree(GetProcessHeap(), 0, iids);
HeapFree(GetProcessHeap(), 0, mapping);
free(iids);
free(mapping);
if (successful_mqis == cMQIs)
return S_OK; /* we got all requested interfaces */
@ -1531,20 +1530,20 @@ static void ifproxy_destroy(struct ifproxy * This)
if (This->proxy) IRpcProxyBuffer_Release(This->proxy);
HeapFree(GetProcessHeap(), 0, This);
free(This);
}
static HRESULT proxy_manager_construct(
struct apartment * apt, ULONG sorflags, OXID oxid, OID oid,
const OXID_INFO *oxid_info, struct proxy_manager ** proxy_manager)
{
struct proxy_manager * This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
struct proxy_manager * This = malloc(sizeof(*This));
if (!This) return E_OUTOFMEMORY;
This->remoting_mutex = CreateMutexW(NULL, FALSE, NULL);
if (!This->remoting_mutex)
{
HeapFree(GetProcessHeap(), 0, This);
free(This);
return HRESULT_FROM_WIN32(GetLastError());
}
@ -1562,7 +1561,7 @@ static HRESULT proxy_manager_construct(
if (FAILED(hr))
{
CloseHandle(This->remoting_mutex);
HeapFree(GetProcessHeap(), 0, This);
free(This);
return hr;
}
}
@ -1718,7 +1717,7 @@ static HRESULT proxy_manager_create_ifproxy(
{
HRESULT hr;
IPSFactoryBuffer * psfb;
struct ifproxy * ifproxy = HeapAlloc(GetProcessHeap(), 0, sizeof(*ifproxy));
struct ifproxy * ifproxy = malloc(sizeof(*ifproxy));
if (!ifproxy) return E_OUTOFMEMORY;
list_init(&ifproxy->entry);
@ -1931,7 +1930,7 @@ static void proxy_manager_destroy(struct proxy_manager * This)
CloseHandle(This->remoting_mutex);
HeapFree(GetProcessHeap(), 0, This);
free(This);
}
/* finds the proxy manager corresponding to a given OXID and OID that has
@ -2014,7 +2013,7 @@ static ULONG WINAPI StdMarshalImpl_Release(IMarshal *iface)
ULONG refcount = InterlockedDecrement(&marshal->refcount);
if (!refcount)
heap_free(marshal);
free(marshal);
return refcount;
}
@ -2215,7 +2214,7 @@ static HRESULT StdMarshalImpl_Construct(REFIID riid, DWORD dest_context, void *d
struct stdmarshal *object;
HRESULT hr;
object = heap_alloc(sizeof(*object));
object = malloc(sizeof(*object));
if (!object)
return E_OUTOFMEMORY;

View File

@ -69,7 +69,7 @@ static HRESULT get_library_for_classid(const WCHAR *classid, WCHAR **out)
hr = REGDB_E_READREGDB;
goto done;
}
if (!(buf = HeapAlloc(GetProcessHeap(), 0, size)))
if (!(buf = malloc(size)))
{
hr = E_OUTOFMEMORY;
goto done;
@ -83,13 +83,13 @@ static HRESULT get_library_for_classid(const WCHAR *classid, WCHAR **out)
{
WCHAR *expanded;
DWORD len = ExpandEnvironmentStringsW(buf, NULL, 0);
if (!(expanded = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
if (!(expanded = malloc(len * sizeof(WCHAR))))
{
hr = E_OUTOFMEMORY;
goto done;
}
ExpandEnvironmentStringsW(buf, expanded, len);
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
buf = expanded;
}
@ -97,7 +97,7 @@ static HRESULT get_library_for_classid(const WCHAR *classid, WCHAR **out)
return S_OK;
done:
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
RegCloseKey(hkey_class);
return hr;
}
@ -178,7 +178,7 @@ HRESULT WINAPI RoGetActivationFactory(HSTRING classid, REFIID iid, void **class_
}
done:
HeapFree(GetProcessHeap(), 0, library);
free(library);
if (module) FreeLibrary(module);
return hr;
}

View File

@ -29,7 +29,6 @@
#include "wine/debug.h"
#include "wine/exception.h"
#include "wine/heap.h"
#include "combase_private.h"
@ -170,12 +169,12 @@ struct channel_hook_buffer_data
};
void * __RPC_USER MIDL_user_allocate(SIZE_T size)
{
return heap_alloc(size);
return malloc(size);
}
void __RPC_USER MIDL_user_free(void *p)
{
heap_free(p);
free(p);
}
static LONG WINAPI rpc_filter(EXCEPTION_POINTERS *eptr)
@ -455,14 +454,14 @@ static HRESULT create_local_service(REFCLSID rclsid)
r = RegQueryValueExW(hkey, L"ServiceParams", NULL, &type, NULL, &sz);
if (r == ERROR_SUCCESS && type == REG_SZ && sz)
{
args[0] = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sz);
args[0] = calloc(1, sz);
num_args++;
RegQueryValueExW(hkey, L"ServiceParams", NULL, &type, (LPBYTE)args[0], &sz);
}
r = start_local_service(buf, num_args, (LPCWSTR *)args);
if (r != ERROR_SUCCESS)
hr = REGDB_E_CLASSNOTREG; /* FIXME: check retval */
HeapFree(GetProcessHeap(),0,args[0]);
free(args[0]);
}
else
{
@ -686,7 +685,7 @@ HRESULT rpc_register_local_server(REFCLSID clsid, IStream *stream, DWORD flags,
if (FAILED(hr)) return hr;
size = GlobalSize(hmem);
if (!(obj = heap_alloc(FIELD_OFFSET(MInterfacePointer, abData[size]))))
if (!(obj = malloc(FIELD_OFFSET(MInterfacePointer, abData[size]))))
return E_OUTOFMEMORY;
obj->ulCntData = size;
ptr = GlobalLock(hmem);
@ -695,7 +694,7 @@ HRESULT rpc_register_local_server(REFCLSID clsid, IStream *stream, DWORD flags,
hr = rpcss_server_register(clsid, flags, obj, cookie);
heap_free(obj);
free(obj);
return hr;
}
@ -721,7 +720,7 @@ static ULONG ChannelHooks_ClientGetSize(SChannelHookCallInfo *info, struct chann
(*hook_count)++;
if (*hook_count)
*data = HeapAlloc(GetProcessHeap(), 0, *hook_count * sizeof(struct channel_hook_buffer_data));
*data = malloc(*hook_count * sizeof(struct channel_hook_buffer_data));
else
*data = NULL;
@ -839,7 +838,7 @@ static ULONG ChannelHooks_ServerGetSize(SChannelHookCallInfo *info,
(*hook_count)++;
if (*hook_count)
*data = HeapAlloc(GetProcessHeap(), 0, *hook_count * sizeof(struct channel_hook_buffer_data));
*data = malloc(*hook_count * sizeof(struct channel_hook_buffer_data));
else
*data = NULL;
@ -946,7 +945,7 @@ HRESULT rpc_register_channel_hook(REFGUID rguid, IChannelHook *hook)
{
struct channel_hook_entry *entry;
entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*entry));
entry = malloc(sizeof(*entry));
if (!entry)
return E_OUTOFMEMORY;
@ -968,7 +967,7 @@ void rpc_unregister_channel_hooks(void)
EnterCriticalSection(&csChannelHook);
LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &channel_hooks, struct channel_hook_entry, entry)
HeapFree(GetProcessHeap(), 0, cursor);
free(cursor);
LeaveCriticalSection(&csChannelHook);
DeleteCriticalSection(&csChannelHook);
DeleteCriticalSection(&csRegIf);
@ -1003,7 +1002,7 @@ static ULONG WINAPI ServerRpcChannelBuffer_Release(LPRPCCHANNELBUFFER iface)
if (ref)
return ref;
HeapFree(GetProcessHeap(), 0, This);
free(This);
return 0;
}
@ -1018,7 +1017,7 @@ static ULONG WINAPI ClientRpcChannelBuffer_Release(LPRPCCHANNELBUFFER iface)
if (This->event) CloseHandle(This->event);
RpcBindingFree(&This->bind);
HeapFree(GetProcessHeap(), 0, This);
free(This);
return 0;
}
@ -1054,12 +1053,12 @@ static HRESULT WINAPI ServerRpcChannelBuffer_GetBuffer(LPRPCCHANNELBUFFER iface,
if (message_state->bypass_rpcrt)
{
msg->Buffer = HeapAlloc(GetProcessHeap(), 0, msg->BufferLength);
msg->Buffer = malloc(msg->BufferLength);
if (msg->Buffer)
status = RPC_S_OK;
else
{
HeapFree(GetProcessHeap(), 0, channel_hook_data);
free(channel_hook_data);
return E_OUTOFMEMORY;
}
}
@ -1103,7 +1102,7 @@ static HRESULT WINAPI ServerRpcChannelBuffer_GetBuffer(LPRPCCHANNELBUFFER iface,
}
}
HeapFree(GetProcessHeap(), 0, channel_hook_data);
free(channel_hook_data);
/* store the prefixed data length so that we can restore the real buffer
* later */
@ -1153,14 +1152,14 @@ static HRESULT WINAPI ClientRpcChannelBuffer_GetBuffer(LPRPCCHANNELBUFFER iface,
TRACE("(%p)->(%p,%s)\n", This, olemsg, debugstr_guid(riid));
cif = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RPC_CLIENT_INTERFACE));
cif = calloc(1, sizeof(RPC_CLIENT_INTERFACE));
if (!cif)
return E_OUTOFMEMORY;
message_state = HeapAlloc(GetProcessHeap(), 0, sizeof(*message_state));
message_state = malloc(sizeof(*message_state));
if (!message_state)
{
HeapFree(GetProcessHeap(), 0, cif);
free(cif);
return E_OUTOFMEMORY;
}
@ -1233,7 +1232,7 @@ static HRESULT WINAPI ClientRpcChannelBuffer_GetBuffer(LPRPCCHANNELBUFFER iface,
/* shortcut the RPC runtime */
if (message_state->target_hwnd)
{
msg->Buffer = HeapAlloc(GetProcessHeap(), 0, msg->BufferLength);
msg->Buffer = malloc(msg->BufferLength);
if (msg->Buffer)
status = RPC_S_OK;
else
@ -1293,7 +1292,7 @@ static HRESULT WINAPI ClientRpcChannelBuffer_GetBuffer(LPRPCCHANNELBUFFER iface,
msg->BufferLength -= message_state->prefix_data_len;
}
HeapFree(GetProcessHeap(), 0, channel_hook_data);
free(channel_hook_data);
TRACE("-- %ld\n", status);
@ -1509,7 +1508,7 @@ static HRESULT WINAPI ServerRpcChannelBuffer_FreeBuffer(LPRPCCHANNELBUFFER iface
if (message_state->bypass_rpcrt)
{
HeapFree(GetProcessHeap(), 0, msg->Buffer);
free(msg->Buffer);
status = RPC_S_OK;
}
else
@ -1538,20 +1537,20 @@ static HRESULT WINAPI ClientRpcChannelBuffer_FreeBuffer(LPRPCCHANNELBUFFER iface
if (message_state->params.bypass_rpcrt)
{
HeapFree(GetProcessHeap(), 0, msg->Buffer);
free(msg->Buffer);
status = RPC_S_OK;
}
else
status = I_RpcFreeBuffer(msg);
HeapFree(GetProcessHeap(), 0, msg->RpcInterfaceInformation);
free(msg->RpcInterfaceInformation);
msg->RpcInterfaceInformation = NULL;
if (message_state->params.stub)
IRpcStubBuffer_Release(message_state->params.stub);
if (message_state->params.chan)
IRpcChannelBuffer_Release(message_state->params.chan);
HeapFree(GetProcessHeap(), 0, message_state);
free(message_state);
TRACE("-- %ld\n", status);
@ -1658,7 +1657,7 @@ HRESULT rpc_create_clientchannel(const OXID *oxid, const IPID *ipid,
return HRESULT_FROM_WIN32(status);
}
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
This = malloc(sizeof(*This));
if (!This)
{
RpcBindingFree(&bind);
@ -1682,7 +1681,7 @@ HRESULT rpc_create_clientchannel(const OXID *oxid, const IPID *ipid,
HRESULT rpc_create_serverchannel(DWORD dest_context, void *dest_context_data, IRpcChannelBuffer **chan)
{
RpcChannelBuffer *This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
RpcChannelBuffer *This = malloc(sizeof(*This));
if (!This)
return E_OUTOFMEMORY;
@ -1871,7 +1870,7 @@ void rpc_execute_call(struct dispatch_params *params)
goto exit;
}
message_state = HeapAlloc(GetProcessHeap(), 0, sizeof(*message_state));
message_state = malloc(sizeof(*message_state));
if (!message_state)
{
params->hr = E_OUTOFMEMORY;
@ -1955,7 +1954,7 @@ void rpc_execute_call(struct dispatch_params *params)
/* the invoke allocated a new buffer, so free the old one */
if (message_state->bypass_rpcrt && original_buffer != msg->Buffer)
HeapFree(GetProcessHeap(), 0, original_buffer);
free(original_buffer);
exit_reset_state:
message_state = msg->Handle;
@ -1964,7 +1963,7 @@ exit_reset_state:
msg->BufferLength += message_state->prefix_data_len;
exit:
HeapFree(GetProcessHeap(), 0, message_state);
free(message_state);
if (params->handle) SetEvent(params->handle);
}
@ -1980,7 +1979,7 @@ static void __RPC_STUB dispatch_rpc(RPC_MESSAGE *msg)
TRACE("ipid = %s, iMethod = %d\n", debugstr_guid(&ipid), msg->ProcNum);
params = HeapAlloc(GetProcessHeap(), 0, sizeof(*params));
params = malloc(sizeof(*params));
if (!params)
{
RpcRaiseException(E_OUTOFMEMORY);
@ -1992,7 +1991,7 @@ static void __RPC_STUB dispatch_rpc(RPC_MESSAGE *msg)
if (hr != S_OK)
{
ERR("no apartment found for ipid %s\n", debugstr_guid(&ipid));
HeapFree(GetProcessHeap(), 0, params);
free(params);
RpcRaiseException(hr);
return;
}
@ -2046,7 +2045,7 @@ static void __RPC_STUB dispatch_rpc(RPC_MESSAGE *msg)
IRpcChannelBuffer_Release(params->chan);
if (params->stub)
IRpcStubBuffer_Release(params->stub);
HeapFree(GetProcessHeap(), 0, params);
free(params);
stub_manager_int_release(stub_manager);
apartment_release(apt);
@ -2079,7 +2078,7 @@ HRESULT rpc_register_interface(REFIID riid)
{
TRACE("Creating new interface\n");
rif = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*rif));
rif = calloc(1, sizeof(*rif));
if (rif)
{
RPC_STATUS status;
@ -2102,7 +2101,7 @@ HRESULT rpc_register_interface(REFIID riid)
else
{
ERR("RpcServerRegisterIfEx failed with error %ld\n", status);
HeapFree(GetProcessHeap(), 0, rif);
free(rif);
hr = HRESULT_FROM_WIN32(status);
}
}
@ -2126,7 +2125,7 @@ void rpc_unregister_interface(REFIID riid, BOOL wait)
{
RpcServerUnregisterIf((RPC_IF_HANDLE)&rif->If, NULL, wait);
list_remove(&rif->entry);
HeapFree(GetProcessHeap(), 0, rif);
free(rif);
}
break;
}

View File

@ -66,7 +66,7 @@ static inline struct hstring_private *impl_from_HSTRING_BUFFER(HSTRING_BUFFER bu
static BOOL alloc_string(UINT32 len, HSTRING *out)
{
struct hstring_private *priv;
priv = HeapAlloc(GetProcessHeap(), 0, offsetof(struct hstring_private, buffer[len+1]));
priv = malloc(offsetof(struct hstring_private, buffer[len+1]));
if (!priv)
return FALSE;
@ -151,7 +151,7 @@ HRESULT WINAPI WindowsDeleteString(HSTRING str)
if (priv->header.flags & HSTRING_REFERENCE_FLAG)
return S_OK;
if (InterlockedDecrement(&priv->refcount) == 0)
HeapFree(GetProcessHeap(), 0, priv);
free(priv);
return S_OK;
}

View File

@ -77,13 +77,13 @@ struct ifstub * stub_manager_new_ifstub(struct stub_manager *m, IRpcStubBuffer *
TRACE("oid=%s, stubbuffer=%p, iid=%s, dest_context=%lx\n", wine_dbgstr_longlong(m->oid), sb,
debugstr_guid(iid), dest_context);
stub = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct ifstub));
stub = calloc(1, sizeof(struct ifstub));
if (!stub) return NULL;
hr = IUnknown_QueryInterface(m->object, iid, (void **)&stub->iface);
if (hr != S_OK)
{
HeapFree(GetProcessHeap(), 0, stub);
free(stub);
return NULL;
}
@ -91,7 +91,7 @@ struct ifstub * stub_manager_new_ifstub(struct stub_manager *m, IRpcStubBuffer *
if (hr != S_OK)
{
IUnknown_Release(stub->iface);
HeapFree(GetProcessHeap(), 0, stub);
free(stub);
return NULL;
}
@ -132,7 +132,7 @@ static void stub_manager_delete_ifstub(struct stub_manager *m, struct ifstub *if
IUnknown_Release(ifstub->iface);
IRpcChannelBuffer_Release(ifstub->chan);
HeapFree(GetProcessHeap(), 0, ifstub);
free(ifstub);
}
static struct ifstub *stub_manager_ipid_to_ifstub(struct stub_manager *m, const IPID *ipid)
@ -182,7 +182,7 @@ static struct stub_manager *new_stub_manager(struct apartment *apt, IUnknown *ob
assert(apt);
sm = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct stub_manager));
sm = calloc(1, sizeof(struct stub_manager));
if (!sm) return NULL;
list_init(&sm->ifstubs);
@ -288,7 +288,7 @@ static void stub_manager_delete(struct stub_manager *m)
m->lock.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&m->lock);
HeapFree(GetProcessHeap(), 0, m);
free(m);
}
/* increments the internal refcount */
@ -634,7 +634,7 @@ static inline RemUnknown *impl_from_IRemUnknown(IRemUnknown *iface)
/* construct an IRemUnknown object with one outstanding reference */
static HRESULT RemUnknown_Construct(IRemUnknown **ppRemUnknown)
{
RemUnknown *object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object));
RemUnknown *object = malloc(sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
@ -683,7 +683,7 @@ static ULONG WINAPI RemUnknown_Release(IRemUnknown *iface)
refs = InterlockedDecrement(&remunk->refs);
if (!refs)
HeapFree(GetProcessHeap(), 0, remunk);
free(remunk);
TRACE("%p after: %ld\n", iface, refs);
return refs;

View File

@ -494,7 +494,7 @@ unsigned char * __RPC_USER HBITMAP_UserUnmarshal(ULONG *flags, unsigned char *bu
bitmap_size = *(ULONG *)buffer;
buffer += sizeof(ULONG);
bits = HeapAlloc(GetProcessHeap(), 0, bitmap_size);
bits = malloc(bitmap_size);
memcpy(&bitmap, buffer, header_size);
buffer += header_size;
@ -505,7 +505,7 @@ unsigned char * __RPC_USER HBITMAP_UserUnmarshal(ULONG *flags, unsigned char *bu
bitmap.bmBits = bits;
*bmp = CreateBitmapIndirect(&bitmap);
HeapFree(GetProcessHeap(), 0, bits);
free(bits);
}
else
*bmp = NULL;