Commit 3bfc4493 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

rpcrt4: Use standard C functions for memory allocation.

parent b3143850
......@@ -329,7 +329,7 @@ HRESULT StdProxy_Construct(REFIID riid,
return RPC_E_UNEXPECTED;
}
This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(StdProxyImpl));
This = calloc(1, sizeof(StdProxyImpl));
if (!This) return E_OUTOFMEMORY;
if (!pUnkOuter) pUnkOuter = (IUnknown *)This;
......@@ -351,7 +351,7 @@ HRESULT StdProxy_Construct(REFIID riid,
&This->base_proxy, (void **)&This->base_object );
if (FAILED(r))
{
HeapFree( GetProcessHeap(), 0, This );
free( This );
return r;
}
}
......@@ -411,7 +411,7 @@ static ULONG WINAPI StdProxy_Release(LPRPCPROXYBUFFER iface)
if (This->base_proxy) IRpcProxyBuffer_Release( This->base_proxy );
IPSFactoryBuffer_Release(This->pPSFactory);
HeapFree(GetProcessHeap(),0,This);
free(This);
}
return refs;
......
......@@ -75,7 +75,7 @@ HRESULT CStdStubBuffer_Construct(REFIID riid,
if(FAILED(r))
return r;
This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(CStdStubBuffer));
This = calloc(1, sizeof(CStdStubBuffer));
if (!This) {
IUnknown_Release(pvServer);
return E_OUTOFMEMORY;
......@@ -296,8 +296,7 @@ IUnknownVtbl *get_delegating_vtbl(DWORD num_methods)
if(!current_vtbl || num_methods > current_vtbl->size)
{
ref_counted_vtbl *table = HeapAlloc(GetProcessHeap(), 0,
FIELD_OFFSET(ref_counted_vtbl, vtbl) + num_methods * sizeof(void*));
ref_counted_vtbl *table = malloc(FIELD_OFFSET(ref_counted_vtbl, vtbl) + num_methods * sizeof(void *));
if (!table)
{
LeaveCriticalSection(&delegating_vtbl_section);
......@@ -311,7 +310,7 @@ IUnknownVtbl *get_delegating_vtbl(DWORD num_methods)
if (current_vtbl && current_vtbl->ref == 0)
{
TRACE("freeing old table\n");
HeapFree(GetProcessHeap(), 0, current_vtbl);
free(current_vtbl);
}
current_vtbl = table;
}
......@@ -332,7 +331,7 @@ void release_delegating_vtbl(IUnknownVtbl *vtbl)
if(table->ref == 0 && table != current_vtbl)
{
TRACE("... and we're not current so free'ing\n");
HeapFree(GetProcessHeap(), 0, table);
free(table);
}
LeaveCriticalSection(&delegating_vtbl_section);
}
......@@ -362,7 +361,7 @@ HRESULT CStdStubBuffer_Delegating_Construct(REFIID riid,
r = IUnknown_QueryInterface(pUnkServer, riid, (void**)&pvServer);
if(FAILED(r)) return r;
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
This = calloc(1, sizeof(*This));
if (!This)
{
IUnknown_Release(pvServer);
......@@ -374,7 +373,7 @@ HRESULT CStdStubBuffer_Delegating_Construct(REFIID riid,
if(FAILED(r))
{
release_delegating_vtbl(This->base_obj);
HeapFree(GetProcessHeap(), 0, This);
free(This);
IUnknown_Release(pvServer);
return r;
}
......@@ -430,7 +429,7 @@ ULONG WINAPI NdrCStdStubBuffer_Release(LPRPCSTUBBUFFER iface,
IRpcStubBuffer_Disconnect(iface);
IPSFactoryBuffer_Release(pPSF);
HeapFree(GetProcessHeap(),0,This);
free(This);
}
return refs;
}
......@@ -454,7 +453,7 @@ ULONG WINAPI NdrCStdStubBuffer2_Release(LPRPCSTUBBUFFER iface,
release_delegating_vtbl(This->base_obj);
IPSFactoryBuffer_Release(pPSF);
HeapFree(GetProcessHeap(), 0, This);
free(This);
}
return refs;
......
......@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdlib.h>
#include "ndr_misc.h"
#include "rpc_assoc.h"
#include "rpcndr.h"
......@@ -140,7 +142,7 @@ RPC_STATUS WINAPI RpcSmDestroyClientContext(void **ContextHandle)
if (che)
{
RpcBindingFree(&che->handle);
HeapFree(GetProcessHeap(), 0, che);
free(che);
}
return status;
......@@ -180,14 +182,14 @@ static RPC_STATUS ndr_update_context_handle(NDR_CCONTEXT *CContext,
return RPC_X_SS_CONTEXT_MISMATCH;
list_remove(&che->entry);
RpcBindingFree(&che->handle);
HeapFree(GetProcessHeap(), 0, che);
free(che);
che = NULL;
}
}
/* if there's no existing entry matching the GUID, allocate one */
else if (!(che = context_entry_from_guid(&chi->uuid)))
{
che = HeapAlloc(GetProcessHeap(), 0, sizeof *che);
che = malloc(sizeof *che);
if (!che)
return RPC_X_NO_MEMORY;
che->magic = NDR_CONTEXT_HANDLE_MAGIC;
......
......@@ -20,6 +20,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
......@@ -55,7 +56,7 @@ RPC_STATUS WINAPI MesEncodeIncrementalHandleCreate(
TRACE("(%p, %p, %p, %p)\n", UserState, AllocFn, WriteFn, pHandle);
pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg));
pEsMsg = malloc(sizeof(*pEsMsg));
if (!pEsMsg)
return RPC_S_OUT_OF_MEMORY;
......@@ -82,7 +83,7 @@ RPC_STATUS WINAPI MesDecodeIncrementalHandleCreate(
TRACE("(%p, %p, %p)\n", UserState, ReadFn, pHandle);
pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg));
pEsMsg = malloc(sizeof(*pEsMsg));
if (!pEsMsg)
return RPC_S_OUT_OF_MEMORY;
......@@ -162,7 +163,7 @@ RPC_STATUS WINAPI MesBufferHandleReset(handle_t Handle, ULONG HandleStyle,
RPC_STATUS WINAPI MesHandleFree(handle_t Handle)
{
TRACE("(%p)\n", Handle);
HeapFree(GetProcessHeap(), 0, Handle);
free(Handle);
return RPC_S_OK;
}
......@@ -196,7 +197,7 @@ RPC_STATUS RPC_ENTRY MesEncodeFixedBufferHandleCreate(
/* FIXME: check BufferSize too */
pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg));
pEsMsg = malloc(sizeof(*pEsMsg));
if (!pEsMsg)
return RPC_S_OUT_OF_MEMORY;
......@@ -226,7 +227,7 @@ RPC_STATUS RPC_ENTRY MesEncodeDynBufferHandleCreate(char **Buffer,
if (!pEncodedSize)
return RPC_S_INVALID_ARG;
pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg));
pEsMsg = malloc(sizeof(*pEsMsg));
if (!pEsMsg)
return RPC_S_OUT_OF_MEMORY;
......@@ -256,7 +257,7 @@ RPC_STATUS RPC_ENTRY MesDecodeBufferHandleCreate(
if ((status = validate_mes_buffer_pointer(Buffer)))
return status;
pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg));
pEsMsg = malloc(sizeof(*pEsMsg));
if (!pEsMsg)
return RPC_S_OUT_OF_MEMORY;
......
......@@ -19,6 +19,7 @@
*/
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
......@@ -33,25 +34,19 @@ PFULL_PTR_XLAT_TABLES WINAPI NdrFullPointerXlatInit(ULONG NumberOfPointers,
XLAT_SIDE XlatSide)
{
ULONG NumberOfBuckets;
PFULL_PTR_XLAT_TABLES pXlatTables = HeapAlloc(GetProcessHeap(), 0, sizeof(*pXlatTables));
FULL_PTR_XLAT_TABLES *pXlatTables = malloc(sizeof(*pXlatTables));
TRACE("(%ld, %d)\n", NumberOfPointers, XlatSide);
if (!NumberOfPointers) NumberOfPointers = 512;
NumberOfBuckets = ((NumberOfPointers + 3) & ~3) - 1;
pXlatTables->RefIdToPointer.XlatTable =
HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(void *) * NumberOfPointers);
pXlatTables->RefIdToPointer.StateTable =
HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(unsigned char) * NumberOfPointers);
pXlatTables->RefIdToPointer.XlatTable = calloc(NumberOfPointers, sizeof(void *));
pXlatTables->RefIdToPointer.StateTable = calloc(NumberOfPointers, sizeof(unsigned char));
pXlatTables->RefIdToPointer.NumberOfEntries = NumberOfPointers;
TRACE("NumberOfBuckets = %ld\n", NumberOfBuckets);
pXlatTables->PointerToRefId.XlatTable =
HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(PFULL_PTR_TO_REFID_ELEMENT) * NumberOfBuckets);
pXlatTables->PointerToRefId.XlatTable = calloc(NumberOfBuckets, sizeof(FULL_PTR_TO_REFID_ELEMENT *));
pXlatTables->PointerToRefId.NumberOfBuckets = NumberOfBuckets;
pXlatTables->PointerToRefId.HashMask = NumberOfBuckets - 1;
......@@ -75,34 +70,36 @@ void WINAPI NdrFullPointerXlatFree(PFULL_PTR_XLAT_TABLES pXlatTables)
XlatTableEntry; )
{
PFULL_PTR_TO_REFID_ELEMENT Next = XlatTableEntry->Next;
HeapFree(GetProcessHeap(), 0, XlatTableEntry);
free(XlatTableEntry);
XlatTableEntry = Next;
}
}
HeapFree(GetProcessHeap(), 0, pXlatTables->RefIdToPointer.XlatTable);
HeapFree(GetProcessHeap(), 0, pXlatTables->RefIdToPointer.StateTable);
HeapFree(GetProcessHeap(), 0, pXlatTables->PointerToRefId.XlatTable);
free(pXlatTables->RefIdToPointer.XlatTable);
free(pXlatTables->RefIdToPointer.StateTable);
free(pXlatTables->PointerToRefId.XlatTable);
HeapFree(GetProcessHeap(), 0, pXlatTables);
free(pXlatTables);
}
static void expand_pointer_table_if_necessary(PFULL_PTR_XLAT_TABLES pXlatTables, ULONG RefId)
{
if (RefId >= pXlatTables->RefIdToPointer.NumberOfEntries)
{
pXlatTables->RefIdToPointer.NumberOfEntries = RefId * 2;
pXlatTables->RefIdToPointer.XlatTable =
HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
pXlatTables->RefIdToPointer.XlatTable,
sizeof(void *) * pXlatTables->RefIdToPointer.NumberOfEntries);
realloc(pXlatTables->RefIdToPointer.XlatTable, sizeof(void *) * RefId * 2);
pXlatTables->RefIdToPointer.StateTable =
HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
pXlatTables->RefIdToPointer.StateTable,
sizeof(unsigned char) * pXlatTables->RefIdToPointer.NumberOfEntries);
realloc(pXlatTables->RefIdToPointer.StateTable, RefId * 2);
if (!pXlatTables->RefIdToPointer.XlatTable || !pXlatTables->RefIdToPointer.StateTable)
{
pXlatTables->RefIdToPointer.NumberOfEntries = 0;
return;
}
memset(pXlatTables->RefIdToPointer.XlatTable + pXlatTables->RefIdToPointer.NumberOfEntries, 0,
(RefId * 2 - pXlatTables->RefIdToPointer.NumberOfEntries) * sizeof(void *));
memset(pXlatTables->RefIdToPointer.StateTable + pXlatTables->RefIdToPointer.NumberOfEntries, 0,
RefId * 2 - pXlatTables->RefIdToPointer.NumberOfEntries);
pXlatTables->RefIdToPointer.NumberOfEntries = RefId * 2;
}
}
......@@ -137,7 +134,7 @@ int WINAPI NdrFullPointerQueryPointer(PFULL_PTR_XLAT_TABLES pXlatTables,
return 0;
}
XlatTableEntry = HeapAlloc(GetProcessHeap(), 0, sizeof(*XlatTableEntry));
XlatTableEntry = malloc(sizeof(*XlatTableEntry));
XlatTableEntry->Next = pXlatTables->PointerToRefId.XlatTable[Hash & pXlatTables->PointerToRefId.HashMask];
XlatTableEntry->Pointer = pPointer;
XlatTableEntry->RefId = *pRefId = pXlatTables->NextRefId++;
......@@ -198,7 +195,7 @@ void WINAPI NdrFullPointerInsertRefId(PFULL_PTR_XLAT_TABLES pXlatTables,
for (i = 0; i < sizeof(pPointer); i++)
Hash = (Hash * 3) ^ ((unsigned char *)&pPointer)[i];
XlatTableEntry = HeapAlloc(GetProcessHeap(), 0, sizeof(*XlatTableEntry));
XlatTableEntry = malloc(sizeof(*XlatTableEntry));
XlatTableEntry->Next = pXlatTables->PointerToRefId.XlatTable[Hash & pXlatTables->PointerToRefId.HashMask];
XlatTableEntry->Pointer = pPointer;
XlatTableEntry->RefId = RefId;
......
......@@ -118,7 +118,7 @@ static ULONG WINAPI RpcStream_Release(LPSTREAM iface)
if (!ref) {
TRACE("size=%ld\n", *This->size);
This->pMsg->Buffer = This->data + *This->size;
HeapFree(GetProcessHeap(),0,This);
free(This);
}
return ref;
}
......@@ -267,7 +267,7 @@ static HRESULT RpcStream_Create(PMIDL_STUB_MESSAGE pStubMsg, BOOL init, ULONG *s
RpcStreamImpl *This;
*stream = NULL;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(RpcStreamImpl));
This = malloc(sizeof(RpcStreamImpl));
if (!This) return E_OUTOFMEMORY;
This->IStream_iface.lpVtbl = &RpcStream_Vtbl;
This->RefCount = 1;
......
......@@ -1248,7 +1248,7 @@ static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg,
case STUBLESS_FREE:
if (params[i].attr.ServerAllocSize)
{
HeapFree(GetProcessHeap(), 0, *(void **)pArg);
free(*(void **)pArg);
}
else if (param_needs_alloc(params[i].attr) &&
(!params[i].attr.MustFree || params[i].attr.IsSimpleRef))
......@@ -1279,8 +1279,7 @@ static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg,
break;
case STUBLESS_UNMARSHAL:
if (params[i].attr.ServerAllocSize)
*(void **)pArg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
params[i].attr.ServerAllocSize * 8);
*(void **)pArg = calloc(params[i].attr.ServerAllocSize, 8);
if (params[i].attr.IsIn)
call_unmarshaller(pStubMsg, &pArg, &params[i], 0);
......@@ -1417,7 +1416,7 @@ LONG WINAPI NdrStubCall2(
TRACE("allocating memory for stack of size %x\n", stack_size);
args = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, stack_size);
args = calloc(1, stack_size);
stubMsg.StackTop = args; /* used by conformance of top-level objects */
/* add the implicit This pointer as the first arg to the function if we
......@@ -1556,7 +1555,7 @@ LONG WINAPI NdrStubCall2(
NdrFullPointerXlatFree(stubMsg.FullPtrXlatTables);
/* free server function stack */
HeapFree(GetProcessHeap(), 0, args);
free(args);
return S_OK;
}
......@@ -2042,7 +2041,7 @@ void RPC_ENTRY NdrAsyncServerCall(PRPC_MESSAGE pRpcMsg)
TRACE("allocating memory for stack of size %x\n", async_call_data->stack_size);
args = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, async_call_data->stack_size);
args = calloc(1, async_call_data->stack_size);
async_call_data->pStubMsg->StackTop = args; /* used by conformance of top-level objects */
pAsync = I_RpcAllocate(sizeof(*pAsync));
......@@ -2160,7 +2159,7 @@ RPC_STATUS NdrpCompleteAsyncServerCall(RPC_ASYNC_STATE *pAsync, void *Reply)
if (async_call_data->pProcHeader->Oi_flags & Oi_OBJECT_PROC)
{
ERR("objects not supported\n");
HeapFree(GetProcessHeap(), 0, async_call_data->pStubMsg->StackTop);
free(async_call_data->pStubMsg->StackTop);
I_RpcFree(async_call_data);
I_RpcFree(pAsync);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
......@@ -2206,7 +2205,7 @@ RPC_STATUS NdrpCompleteAsyncServerCall(RPC_ASYNC_STATE *pAsync, void *Reply)
#endif
/* free server function stack */
HeapFree(GetProcessHeap(), 0, async_call_data->pStubMsg->StackTop);
free(async_call_data->pStubMsg->StackTop);
I_RpcFree(async_call_data);
I_RpcFree(pAsync);
......
......@@ -26,7 +26,6 @@
#include "rpcproxy.h"
#include "ndrtypes.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "cpsf.h"
#include "initguid.h"
......@@ -1187,9 +1186,9 @@ static HRESULT build_format_strings(ITypeInfo *typeinfo, WORD funcs,
hr = write_iface_fs(typeinfo, funcs, parentfuncs, NULL, &typelen, NULL, &proclen, NULL);
if (FAILED(hr)) return hr;
type = heap_alloc(typelen);
proc = heap_alloc(proclen);
offset = heap_alloc((parentfuncs + funcs - 3) * sizeof(*offset));
type = malloc(typelen);
proc = malloc(proclen);
offset = malloc((parentfuncs + funcs - 3) * sizeof(*offset));
if (!type || !proc || !offset)
{
ERR("Failed to allocate format strings.\n");
......@@ -1211,9 +1210,9 @@ static HRESULT build_format_strings(ITypeInfo *typeinfo, WORD funcs,
}
err:
heap_free(type);
heap_free(proc);
heap_free(offset);
free(type);
free(proc);
free(offset);
return hr;
}
......@@ -1328,11 +1327,11 @@ static ULONG WINAPI typelib_proxy_Release(IRpcProxyBuffer *iface)
IUnknown_Release(proxy->proxy.base_object);
if (proxy->proxy.base_proxy)
IRpcProxyBuffer_Release(proxy->proxy.base_proxy);
heap_free((void *)proxy->stub_desc.pFormatTypes);
heap_free((void *)proxy->proxy_info.ProcFormatString);
heap_free(proxy->offset_table);
heap_free(proxy->proxy_vtbl);
heap_free(proxy);
free((void *)proxy->stub_desc.pFormatTypes);
free((void *)proxy->proxy_info.ProcFormatString);
free(proxy->offset_table);
free(proxy->proxy_vtbl);
free(proxy);
}
return refcount;
}
......@@ -1390,7 +1389,7 @@ HRESULT WINAPI CreateProxyFromTypeInfo(ITypeInfo *typeinfo, IUnknown *outer,
if (FAILED(hr))
return hr;
if (!(proxy = heap_alloc_zero(sizeof(*proxy))))
if (!(proxy = calloc(1, sizeof(*proxy))))
{
ERR("Failed to allocate proxy object.\n");
ITypeInfo_Release(real_typeinfo);
......@@ -1400,11 +1399,11 @@ HRESULT WINAPI CreateProxyFromTypeInfo(ITypeInfo *typeinfo, IUnknown *outer,
init_stub_desc(&proxy->stub_desc);
proxy->proxy_info.pStubDesc = &proxy->stub_desc;
proxy->proxy_vtbl = heap_alloc_zero(sizeof(proxy->proxy_vtbl->header) + (funcs + parentfuncs) * sizeof(void *));
proxy->proxy_vtbl = calloc(1, sizeof(proxy->proxy_vtbl->header) + (funcs + parentfuncs) * sizeof(void *));
if (!proxy->proxy_vtbl)
{
ERR("Failed to allocate proxy vtbl.\n");
heap_free(proxy);
free(proxy);
ITypeInfo_Release(real_typeinfo);
return E_OUTOFMEMORY;
}
......@@ -1420,8 +1419,8 @@ HRESULT WINAPI CreateProxyFromTypeInfo(ITypeInfo *typeinfo, IUnknown *outer,
ITypeInfo_Release(real_typeinfo);
if (FAILED(hr))
{
heap_free(proxy->proxy_vtbl);
heap_free(proxy);
free(proxy->proxy_vtbl);
free(proxy);
return hr;
}
proxy->proxy_info.FormatStringOffset = &proxy->offset_table[-3];
......@@ -1429,11 +1428,11 @@ HRESULT WINAPI CreateProxyFromTypeInfo(ITypeInfo *typeinfo, IUnknown *outer,
hr = typelib_proxy_init(proxy, outer, funcs + parentfuncs, &parentiid, proxy_buffer, out);
if (FAILED(hr))
{
heap_free((void *)proxy->stub_desc.pFormatTypes);
heap_free((void *)proxy->proxy_info.ProcFormatString);
heap_free((void *)proxy->offset_table);
heap_free(proxy->proxy_vtbl);
heap_free(proxy);
free((void *)proxy->stub_desc.pFormatTypes);
free((void *)proxy->proxy_info.ProcFormatString);
free((void *)proxy->offset_table);
free(proxy->proxy_vtbl);
free(proxy);
}
return hr;
......@@ -1467,13 +1466,13 @@ static ULONG WINAPI typelib_stub_Release(IRpcStubBuffer *iface)
{
IRpcStubBuffer_Release(stub->stub.base_stub);
release_delegating_vtbl(stub->stub.base_obj);
heap_free(stub->dispatch_table);
free(stub->dispatch_table);
}
heap_free((void *)stub->stub_desc.pFormatTypes);
heap_free((void *)stub->server_info.ProcString);
heap_free(stub->offset_table);
heap_free(stub);
free((void *)stub->stub_desc.pFormatTypes);
free((void *)stub->server_info.ProcString);
free(stub->offset_table);
free(stub);
}
return refcount;
......@@ -1529,7 +1528,7 @@ HRESULT WINAPI CreateStubFromTypeInfo(ITypeInfo *typeinfo, REFIID iid,
if (FAILED(hr))
return hr;
if (!(stub = heap_alloc_zero(sizeof(*stub))))
if (!(stub = calloc(1, sizeof(*stub))))
{
ERR("Failed to allocate stub object.\n");
ITypeInfo_Release(real_typeinfo);
......@@ -1544,7 +1543,7 @@ HRESULT WINAPI CreateStubFromTypeInfo(ITypeInfo *typeinfo, REFIID iid,
ITypeInfo_Release(real_typeinfo);
if (FAILED(hr))
{
heap_free(stub);
free(stub);
return hr;
}
stub->server_info.FmtStringOffset = &stub->offset_table[-3];
......@@ -1556,7 +1555,7 @@ HRESULT WINAPI CreateStubFromTypeInfo(ITypeInfo *typeinfo, REFIID iid,
if (!IsEqualGUID(&parentiid, &IID_IUnknown))
{
stub->dispatch_table = heap_alloc((funcs + parentfuncs) * sizeof(void *));
stub->dispatch_table = malloc((funcs + parentfuncs) * sizeof(void *));
for (i = 3; i < parentfuncs; i++)
stub->dispatch_table[i - 3] = NdrStubForwardingFunction;
for (; i < funcs + parentfuncs; i++)
......@@ -1571,10 +1570,10 @@ HRESULT WINAPI CreateStubFromTypeInfo(ITypeInfo *typeinfo, REFIID iid,
hr = typelib_stub_init(stub, server, &parentiid, stub_buffer);
if (FAILED(hr))
{
heap_free((void *)stub->stub_desc.pFormatTypes);
heap_free((void *)stub->server_info.ProcString);
heap_free(stub->offset_table);
heap_free(stub);
free((void *)stub->stub_desc.pFormatTypes);
free((void *)stub->server_info.ProcString);
free(stub->offset_table);
free(stub);
}
return hr;
......
......@@ -20,6 +20,7 @@
*/
#include <stdarg.h>
#include <stdlib.h>
#include <assert.h>
#include "rpc.h"
......@@ -65,7 +66,7 @@ static RPC_STATUS RpcAssoc_Alloc(LPCSTR Protseq, LPCSTR NetworkAddr,
RpcAssoc **assoc_out)
{
RpcAssoc *assoc;
assoc = HeapAlloc(GetProcessHeap(), 0, sizeof(*assoc));
assoc = malloc(sizeof(*assoc));
if (!assoc)
return RPC_S_OUT_OF_RESOURCES;
assoc->refs = 1;
......@@ -73,10 +74,10 @@ static RPC_STATUS RpcAssoc_Alloc(LPCSTR Protseq, LPCSTR NetworkAddr,
list_init(&assoc->context_handle_list);
InitializeCriticalSection(&assoc->cs);
assoc->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcAssoc.cs");
assoc->Protseq = RPCRT4_strdupA(Protseq);
assoc->NetworkAddr = RPCRT4_strdupA(NetworkAddr);
assoc->Endpoint = RPCRT4_strdupA(Endpoint);
assoc->NetworkOptions = NetworkOptions ? RPCRT4_strdupW(NetworkOptions) : NULL;
assoc->Protseq = strdup(Protseq);
assoc->NetworkAddr = strdup(NetworkAddr);
assoc->Endpoint = strdup(Endpoint);
assoc->NetworkOptions = wcsdup(NetworkOptions);
assoc->assoc_group_id = 0;
assoc->connection_cnt = 0;
UuidCreate(&assoc->http_uuid);
......@@ -209,15 +210,15 @@ ULONG RpcAssoc_Release(RpcAssoc *assoc)
LIST_FOR_EACH_ENTRY_SAFE(context_handle, context_handle_cursor, &assoc->context_handle_list, RpcContextHandle, entry)
RpcContextHandle_Destroy(context_handle);
HeapFree(GetProcessHeap(), 0, assoc->NetworkOptions);
HeapFree(GetProcessHeap(), 0, assoc->Endpoint);
HeapFree(GetProcessHeap(), 0, assoc->NetworkAddr);
HeapFree(GetProcessHeap(), 0, assoc->Protseq);
free(assoc->NetworkOptions);
free(assoc->Endpoint);
free(assoc->NetworkAddr);
free(assoc->Protseq);
assoc->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&assoc->cs);
HeapFree(GetProcessHeap(), 0, assoc);
free(assoc);
}
return refs;
......@@ -244,7 +245,7 @@ static RPC_STATUS RpcAssoc_BindConnection(const RpcAssoc *assoc, RpcConnection *
InterfaceId, TransferSyntax);
status = RPCRT4_Send(conn, hdr, NULL, 0);
RPCRT4_FreeHeader(hdr);
free(hdr);
if (status != RPC_S_OK)
return status;
......@@ -355,8 +356,8 @@ static RPC_STATUS RpcAssoc_BindConnection(const RpcAssoc *assoc, RpcConnection *
}
I_RpcFree(msg.Buffer);
RPCRT4_FreeHeader(response_hdr);
HeapFree(GetProcessHeap(), 0, auth_data);
free(response_hdr);
free(auth_data);
return status;
}
......@@ -457,7 +458,7 @@ RPC_STATUS RpcServerAssoc_AllocateContextHandle(RpcAssoc *assoc, void *CtxGuard,
{
RpcContextHandle *context_handle;
context_handle = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*context_handle));
context_handle = calloc(1, sizeof(*context_handle));
if (!context_handle)
return RPC_S_OUT_OF_MEMORY;
......@@ -558,7 +559,7 @@ static void RpcContextHandle_Destroy(RpcContextHandle *context_handle)
context_handle->lock.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&context_handle->lock);
HeapFree(GetProcessHeap(), 0, context_handle);
free(context_handle);
}
unsigned int RpcServerAssoc_ReleaseContextHandle(RpcAssoc *assoc, NDR_SCONTEXT SContext, BOOL release_lock)
......
......@@ -147,10 +147,6 @@ LPSTR RPCRT4_strndupA(LPCSTR src, INT len) DECLSPEC_HIDDEN;
LPWSTR RPCRT4_strndupW(LPCWSTR src, INT len) DECLSPEC_HIDDEN;
LPSTR RPCRT4_strdupWtoA(LPCWSTR src) DECLSPEC_HIDDEN;
LPWSTR RPCRT4_strdupAtoW(LPCSTR src) DECLSPEC_HIDDEN;
void RPCRT4_strfree(LPSTR src) DECLSPEC_HIDDEN;
#define RPCRT4_strdupA(x) RPCRT4_strndupA((x),-1)
#define RPCRT4_strdupW(x) RPCRT4_strndupW((x),-1)
RPC_STATUS RpcAuthInfo_Create(ULONG AuthnLevel, ULONG AuthnSvc, CredHandle cred, TimeStamp exp, ULONG cbMaxToken, RPC_AUTH_IDENTITY_HANDLE identity, RpcAuthInfo **ret) DECLSPEC_HIDDEN;
ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo) DECLSPEC_HIDDEN;
......
......@@ -216,14 +216,14 @@ static RPC_STATUS epm_register( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *Bindin
if (!BindingVector->Count) return RPC_S_OK;
entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*entries) * BindingVector->Count * (UuidVector ? UuidVector->Count : 1));
entries = calloc(BindingVector->Count * (UuidVector ? UuidVector->Count : 1), sizeof(*entries));
if (!entries)
return RPC_S_OUT_OF_MEMORY;
status = get_epm_handle_server(&handle);
if (status != RPC_S_OK)
{
HeapFree(GetProcessHeap(), 0, entries);
free(entries);
return status;
}
......@@ -284,7 +284,7 @@ static RPC_STATUS epm_register( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *Bindin
I_RpcFree(entries[i*(UuidVector ? UuidVector->Count : 1) + j].tower);
}
HeapFree(GetProcessHeap(), 0, entries);
free(entries);
return status;
}
......@@ -318,7 +318,7 @@ RPC_STATUS WINAPI RpcEpRegisterW( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *Bind
status = epm_register(IfSpec, BindingVector, UuidVector, (RPC_CSTR)annA, TRUE);
HeapFree(GetProcessHeap(), 0, annA);
free(annA);
return status;
}
......@@ -333,7 +333,7 @@ RPC_STATUS WINAPI RpcEpRegisterNoReplaceW( RPC_IF_HANDLE IfSpec, RPC_BINDING_VEC
status = epm_register(IfSpec, BindingVector, UuidVector, (RPC_CSTR)annA, FALSE);
HeapFree(GetProcessHeap(), 0, annA);
free(annA);
return status;
}
......@@ -362,14 +362,14 @@ RPC_STATUS WINAPI RpcEpUnregister( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *Bin
TRACE(" obj[%ld]=%s\n", i, debugstr_guid(UuidVector->Uuid[i]));
}
entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*entries) * BindingVector->Count * (UuidVector ? UuidVector->Count : 1));
entries = calloc(BindingVector->Count * (UuidVector ? UuidVector->Count : 1), sizeof(*entries));
if (!entries)
return RPC_S_OUT_OF_MEMORY;
status = get_epm_handle_server(&handle);
if (status != RPC_S_OK)
{
HeapFree(GetProcessHeap(), 0, entries);
free(entries);
return status;
}
......@@ -419,7 +419,7 @@ RPC_STATUS WINAPI RpcEpUnregister( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *Bin
I_RpcFree(entries[i*(UuidVector ? UuidVector->Count : 1) + j].tower);
}
HeapFree(GetProcessHeap(), 0, entries);
free(entries);
return status;
}
......@@ -655,10 +655,10 @@ RPC_STATUS WINAPI TowerConstruct(
void __RPC_FAR * __RPC_USER MIDL_user_allocate(SIZE_T len)
{
return HeapAlloc(GetProcessHeap(), 0, len);
return malloc(len);
}
void __RPC_USER MIDL_user_free(void __RPC_FAR * ptr)
{
HeapFree(GetProcessHeap(), 0, ptr);
free(ptr);
}
......@@ -33,7 +33,6 @@ RpcPktHdr *RPCRT4_BuildBindAckHeader(ULONG DataRepresentation, unsigned short Ma
RpcPktHdr *RPCRT4_BuildHttpHeader(ULONG DataRepresentation, unsigned short flags, unsigned short num_data_items, unsigned int payload_size) DECLSPEC_HIDDEN;
RpcPktHdr *RPCRT4_BuildHttpConnectHeader(int out_pipe, const UUID *connection_uuid, const UUID *pipe_uuid, const UUID *association_uuid) DECLSPEC_HIDDEN;
RpcPktHdr *RPCRT4_BuildHttpFlowControlHeader(BOOL server, ULONG bytes_transmitted, ULONG flow_control_increment, const UUID *pipe_uuid) DECLSPEC_HIDDEN;
VOID RPCRT4_FreeHeader(RpcPktHdr *Header) DECLSPEC_HIDDEN;
RPC_STATUS RPCRT4_Send(RpcConnection *Connection, RpcPktHdr *Header, void *Buffer, unsigned int BufferLength) DECLSPEC_HIDDEN;
RPC_STATUS RPCRT4_SendWithAuth(RpcConnection *Connection, RpcPktHdr *Header, void *Buffer, unsigned int BufferLength, const void *Auth, unsigned int AuthLength) DECLSPEC_HIDDEN;
RPC_STATUS RPCRT4_ReceiveWithAuth(RpcConnection *Connection, RpcPktHdr **Header, PRPC_MESSAGE pMsg, unsigned char **auth_data_out, ULONG *auth_length_out) DECLSPEC_HIDDEN;
......
......@@ -136,7 +136,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
ERR("tdata->connection should be NULL but is still set to %p\n", tdata->connection);
if (tdata->server_binding)
ERR("tdata->server_binding should be NULL but is still set to %p\n", tdata->server_binding);
HeapFree(GetProcessHeap(), 0, tdata);
free(tdata);
}
break;
......@@ -163,7 +163,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
*/
RPC_STATUS WINAPI RpcStringFreeA(RPC_CSTR* String)
{
HeapFree( GetProcessHeap(), 0, *String);
free(*String);
return RPC_S_OK;
}
......@@ -179,7 +179,7 @@ RPC_STATUS WINAPI RpcStringFreeA(RPC_CSTR* String)
*/
RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR* String)
{
HeapFree( GetProcessHeap(), 0, *String);
free(*String);
return RPC_S_OK;
}
......@@ -370,11 +370,11 @@ static RPC_STATUS RPC_UuidGetNodeAddress(BYTE *address)
DWORD status = RPC_S_OK;
ULONG buflen = sizeof(IP_ADAPTER_INFO);
PIP_ADAPTER_INFO adapter = HeapAlloc(GetProcessHeap(), 0, buflen);
PIP_ADAPTER_INFO adapter = malloc(buflen);
if (GetAdaptersInfo(adapter, &buflen) == ERROR_BUFFER_OVERFLOW) {
HeapFree(GetProcessHeap(), 0, adapter);
adapter = HeapAlloc(GetProcessHeap(), 0, buflen);
free(adapter);
adapter = malloc(buflen);
}
if (GetAdaptersInfo(adapter, &buflen) == NO_ERROR) {
......@@ -390,7 +390,7 @@ static RPC_STATUS RPC_UuidGetNodeAddress(BYTE *address)
status = RPC_S_UUID_LOCAL_ONLY;
}
HeapFree(GetProcessHeap(), 0, adapter);
free(adapter);
return status;
}
......@@ -536,7 +536,7 @@ unsigned short WINAPI UuidHash(UUID *uuid, RPC_STATUS *Status)
*/
RPC_STATUS WINAPI UuidToStringA(UUID *Uuid, RPC_CSTR* StringUuid)
{
*StringUuid = HeapAlloc( GetProcessHeap(), 0, sizeof(char) * 37);
*StringUuid = malloc(37);
if(!(*StringUuid))
return RPC_S_OUT_OF_MEMORY;
......@@ -728,7 +728,7 @@ RPC_STATUS RPC_ENTRY DceErrorInqTextA (RPC_STATUS e, RPC_CSTR buffer)
*/
void * WINAPI I_RpcAllocate(unsigned int Size)
{
return HeapAlloc(GetProcessHeap(), 0, Size);
return malloc(Size);
}
/******************************************************************************
......@@ -736,7 +736,7 @@ void * WINAPI I_RpcAllocate(unsigned int Size)
*/
void WINAPI I_RpcFree(void *Object)
{
HeapFree(GetProcessHeap(), 0, Object);
free(Object);
}
/******************************************************************************
......@@ -947,7 +947,7 @@ static struct threaddata *get_or_create_threaddata(void)
struct threaddata *tdata = NtCurrentTeb()->ReservedForNtRpc;
if (!tdata)
{
tdata = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*tdata));
tdata = calloc(1, sizeof(*tdata));
if (!tdata) return NULL;
InitializeCriticalSection(&tdata->cs);
......@@ -997,7 +997,7 @@ void RPCRT4_PushThreadContextHandle(NDR_SCONTEXT SContext)
if (!tdata) return;
context_handle_list = HeapAlloc(GetProcessHeap(), 0, sizeof(*context_handle_list));
context_handle_list = malloc(sizeof(*context_handle_list));
if (!context_handle_list) return;
context_handle_list->context_handle = SContext;
......@@ -1020,7 +1020,7 @@ void RPCRT4_RemoveThreadContextHandle(NDR_SCONTEXT SContext)
prev->next = current->next;
else
tdata->context_handle_list = current->next;
HeapFree(GetProcessHeap(), 0, current);
free(current);
return;
}
}
......@@ -1039,7 +1039,7 @@ NDR_SCONTEXT RPCRT4_PopThreadContextHandle(void)
tdata->context_handle_list = context_handle_list->next;
context_handle = context_handle_list->context_handle;
HeapFree(GetProcessHeap(), 0, context_handle_list);
free(context_handle_list);
return context_handle;
}
......
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