rpcrt4/tests: Use CRT allocation functions.

This commit is contained in:
Alex Henrie 2023-11-06 00:10:47 -07:00 committed by Alexandre Julliard
parent 1bab7ea25e
commit a38e05636d
4 changed files with 116 additions and 127 deletions

View file

@ -34,7 +34,6 @@
#include "rpcdce.h"
#include "rpcproxy.h"
#include "wine/heap.h"
#include "wine/test.h"
#include "cstub.h"
@ -1082,7 +1081,7 @@ static HRESULT WINAPI delegating_invoke_chan_get_buffer(IRpcChannelBuffer *pchan
RPCOLEMESSAGE *msg,
REFIID iid)
{
msg->Buffer = HeapAlloc(GetProcessHeap(), 0, msg->cbBuffer);
msg->Buffer = malloc(msg->cbBuffer);
return S_OK;
}
@ -1149,7 +1148,7 @@ static void test_delegating_Invoke(IPSFactoryBuffer *ppsf)
ok(*((DWORD*)msg.Buffer + 1) == S_OK, "buf[1] %08lx\n", *((DWORD*)msg.Buffer + 1));
}
/* free the buffer allocated by delegating_invoke_chan_get_buffer */
HeapFree(GetProcessHeap(), 0, msg.Buffer);
free(msg.Buffer);
IRpcStubBuffer_Release(pstub);
}
static const CInterfaceProxyVtbl *cstub_ProxyVtblList2[] =
@ -1300,7 +1299,7 @@ static ULONG WINAPI test_cf_Release(IClassFactory *iface)
static HRESULT WINAPI test_cf_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID iid, void **out)
{
ITest1 *obj = heap_alloc(sizeof(*obj));
ITest1 *obj = malloc(sizeof(*obj));
obj->lpVtbl = &test1_vtbl;

View file

@ -34,7 +34,6 @@
#include "midles.h"
#include "ndrtypes.h"
#include "wine/heap.h"
#include "wine/test.h"
static int my_alloc_called;
@ -126,14 +125,14 @@ static void determine_pointer_marshalling_style(void)
0);
StubMsg.BufferLength = 8;
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = malloc(StubMsg.BufferLength);
NdrPointerMarshall(&StubMsg, (unsigned char*)&ch, fmtstr_up_char);
ok(StubMsg.Buffer == StubMsg.BufferStart + 5, "%p %p\n", StubMsg.Buffer, StubMsg.BufferStart);
use_pointer_ids = (*(unsigned int *)StubMsg.BufferStart != (UINT_PTR)&ch);
trace("Pointer marshalling using %s\n", use_pointer_ids ? "pointer ids" : "pointer value");
HeapFree(GetProcessHeap(), 0, StubMsg.BufferStart);
free(StubMsg.BufferStart);
}
static void test_ndr_simple_type(void)
@ -153,7 +152,7 @@ static void test_ndr_simple_type(void)
0);
StubMsg.BufferLength = 16;
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = malloc(StubMsg.BufferLength);
StubMsg.BufferEnd = StubMsg.Buffer + StubMsg.BufferLength;
l = 0xcafebabe;
NdrSimpleTypeMarshall(&StubMsg, (unsigned char*)&l, FC_LONG);
@ -170,7 +169,7 @@ static void test_ndr_simple_type(void)
ok(StubMsg.Buffer == StubMsg.BufferStart + 8, "%p %p\n", StubMsg.Buffer, StubMsg.BufferStart);
ok(l2 == l, "%ld\n", l2);
HeapFree(GetProcessHeap(), 0, StubMsg.BufferStart);
free(StubMsg.BufferStart);
}
static void test_pointer_marshal(const unsigned char *formattypes,
@ -207,7 +206,7 @@ static void test_pointer_marshal(const unsigned char *formattypes,
ok(StubMsg.BufferLength >= wiredatalen, "%s: length %ld\n", msgpfx, StubMsg.BufferLength);
/*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = malloc(StubMsg.BufferLength);
StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength;
memset(StubMsg.BufferStart, 0x0, StubMsg.BufferLength); /* This is a hack to clear the padding between the ptr and longlong/double */
@ -282,7 +281,7 @@ static void test_pointer_marshal(const unsigned char *formattypes,
{
/* In this case the top-level pointer is not freed. */
ok(my_free_called == num_additional_allocs, "%s: my_free got called %d times\n", msgpfx, my_free_called);
HeapFree(GetProcessHeap(), 0, mem);
free(mem);
}
else
ok(my_free_called == 1 + num_additional_allocs, "%s: my_free got called %d times\n", msgpfx, my_free_called);
@ -290,7 +289,7 @@ static void test_pointer_marshal(const unsigned char *formattypes,
/* reset the buffer and call with must alloc */
my_alloc_called = my_free_called = 0;
StubMsg.Buffer = StubMsg.BufferStart;
mem_orig = mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
mem_orig = mem = calloc(1, size);
if (formattypes[1] & FC_POINTER_DEREF)
*(void**)mem = NULL;
ptr = NdrPointerUnmarshall( &StubMsg, &mem, formattypes, 1 );
@ -308,7 +307,7 @@ static void test_pointer_marshal(const unsigned char *formattypes,
{
/* In this case the top-level pointer is not freed. */
ok(my_free_called == num_additional_allocs, "%s: my_free got called %d times\n", msgpfx, my_free_called);
HeapFree(GetProcessHeap(), 0, mem);
free(mem);
}
else
ok(my_free_called == 1 + num_additional_allocs, "%s: my_free got called %d times\n", msgpfx, my_free_called);
@ -383,7 +382,7 @@ static void test_pointer_marshal(const unsigned char *formattypes,
* stack memory. In practice it always *is* stack memory if ON_STACK is
* set, so this leak isn't a concern. */
ok(my_free_called == 0, "%s: my_free got called %d times\n", msgpfx, my_free_called);
HeapFree(GetProcessHeap(), 0, mem);
free(mem);
}
else
ok(my_free_called == num_additional_allocs, "%s: my_free got called %d times\n", msgpfx, my_free_called);
@ -410,7 +409,7 @@ static void test_pointer_marshal(const unsigned char *formattypes,
else if ((formattypes[1] & FC_ALLOCED_ON_STACK) && (formattypes[1] & FC_POINTER_DEREF))
{
ok(my_free_called == 0, "%s: my_free got called %d times\n", msgpfx, my_free_called);
HeapFree(GetProcessHeap(), 0, mem);
free(mem);
}
else
ok(my_free_called == num_additional_allocs, "%s: my_free got called %d times\n", msgpfx, my_free_called);
@ -421,7 +420,7 @@ static void test_pointer_marshal(const unsigned char *formattypes,
my_alloc_called = my_free_called = 0;
StubMsg.Buffer = StubMsg.BufferStart;
mem_orig = mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
mem_orig = mem = calloc(1, size);
if (formattypes[1] & FC_POINTER_DEREF)
*(void**)mem = NULL;
ptr = NdrPointerUnmarshall( &StubMsg, &mem, formattypes, 0 );
@ -431,7 +430,7 @@ static void test_pointer_marshal(const unsigned char *formattypes,
else
{
ok(mem != mem_orig, "%s: mem has not changed\n", msgpfx);
HeapFree(GetProcessHeap(), 0, mem_orig);
free(mem_orig);
}
ok(!cmp(mem, memsrc, srcsize), "%s: incorrectly unmarshaled\n", msgpfx);
ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen);
@ -450,7 +449,7 @@ static void test_pointer_marshal(const unsigned char *formattypes,
else if ((formattypes[1] & FC_ALLOCED_ON_STACK) && (formattypes[1] & FC_POINTER_DEREF))
{
ok(my_free_called == 0, "%s: my_free got called %d times\n", msgpfx, my_free_called);
HeapFree(GetProcessHeap(), 0, mem);
free(mem);
}
else
ok(my_free_called == num_additional_allocs, "%s: my_free got called %d times\n", msgpfx, my_free_called);
@ -458,7 +457,7 @@ static void test_pointer_marshal(const unsigned char *formattypes,
/* reset the buffer and call with must alloc */
my_alloc_called = my_free_called = 0;
StubMsg.Buffer = StubMsg.BufferStart;
mem_orig = mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
mem_orig = mem = calloc(1, size);
if (formattypes[1] & FC_POINTER_DEREF)
*(void**)mem = NULL;
ptr = NdrPointerUnmarshall( &StubMsg, &mem, formattypes, 1 );
@ -468,7 +467,7 @@ static void test_pointer_marshal(const unsigned char *formattypes,
else
{
ok(mem != mem_orig, "%s: mem has not changed\n", msgpfx);
HeapFree(GetProcessHeap(), 0, mem_orig);
free(mem_orig);
}
ok(!cmp(mem, memsrc, srcsize), "%s: incorrectly unmarshaled\n", msgpfx);
ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen);
@ -487,12 +486,12 @@ static void test_pointer_marshal(const unsigned char *formattypes,
else if ((formattypes[1] & FC_ALLOCED_ON_STACK) && (formattypes[1] & FC_POINTER_DEREF))
{
ok(my_free_called == 0, "%s: my_free got called %d times\n", msgpfx, my_free_called);
HeapFree(GetProcessHeap(), 0, mem);
free(mem);
}
else
ok(my_free_called == num_additional_allocs, "%s: my_free got called %d times\n", msgpfx, my_free_called);
HeapFree(GetProcessHeap(), 0, StubMsg.BufferStart);
free(StubMsg.BufferStart);
}
static int deref_cmp(const void *s1, const void *s2, size_t num)
@ -757,7 +756,7 @@ static void test_nontrivial_pointer_types(void)
ok(StubMsg.BufferLength >= 5, "length %ld\n", StubMsg.BufferLength);
/*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = malloc(StubMsg.BufferLength);
StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength;
ptr = NdrPointerMarshall( &StubMsg, (unsigned char *)p1, &fmtstr_ref_unique_out[4] );
@ -775,7 +774,7 @@ static void test_nontrivial_pointer_types(void)
/* Client */
my_alloc_called = 0;
StubMsg.Buffer = StubMsg.BufferStart;
mem = mem_orig = HeapAlloc(GetProcessHeap(), 0, sizeof(void *));
mem = mem_orig = malloc(sizeof(void *));
*(void **)mem = NULL;
NdrPointerUnmarshall( &StubMsg, &mem, &fmtstr_ref_unique_out[4], 0);
ok(mem == mem_orig, "mem alloced\n");
@ -864,8 +863,8 @@ static void test_nontrivial_pointer_types(void)
ok(my_free_called == 1, "free called %d\n", my_free_called);
my_free(mem);
HeapFree(GetProcessHeap(), 0, mem_orig);
HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer);
free(mem_orig);
free(StubMsg.RpcMsg->Buffer);
}
static void test_simple_struct_marshal(const unsigned char *formattypes,
@ -895,7 +894,7 @@ static void test_simple_struct_marshal(const unsigned char *formattypes,
StubMsg.BufferLength = 0;
NdrSimpleStructBufferSize( &StubMsg, memsrc, formattypes );
ok(StubMsg.BufferLength >= wiredatalen, "%s: length %ld\n", msgpfx, StubMsg.BufferLength);
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = malloc(StubMsg.BufferLength);
StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength;
ptr = NdrSimpleStructMarshall( &StubMsg, memsrc, formattypes );
ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr);
@ -919,7 +918,7 @@ static void test_simple_struct_marshal(const unsigned char *formattypes,
StubMsg.Buffer = StubMsg.BufferStart;
StubMsg.MemorySize = 0;
mem_orig = mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, srcsize);
mem_orig = mem = calloc(1, srcsize);
ptr = NdrSimpleStructUnmarshall( &StubMsg, &mem, formattypes, 0 );
ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr);
ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart);
@ -1032,8 +1031,8 @@ static void test_simple_struct_marshal(const unsigned char *formattypes,
ok(my_free_called == num_additional_allocs, "free called %d\n", my_free_called);
my_free(mem);
HeapFree(GetProcessHeap(), 0, mem_orig);
HeapFree(GetProcessHeap(), 0, StubMsg.BufferStart);
free(mem_orig);
free(StubMsg.BufferStart);
}
typedef struct
@ -1238,7 +1237,7 @@ static void test_struct_align(void)
0x5b, /* FC_END */
};
memsrc_orig = heap_alloc_zero(sizeof(struct aligned) + 8);
memsrc_orig = calloc(1, sizeof(struct aligned) + 8);
/* intentionally mis-align memsrc */
memsrc = (struct aligned *)((((ULONG_PTR)memsrc_orig + 7) & ~7) + 4);
@ -1252,7 +1251,7 @@ static void test_struct_align(void)
StubMsg.BufferLength = 0;
NdrComplexStructBufferSize(&StubMsg, (unsigned char *)memsrc, fmtstr);
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = heap_alloc(StubMsg.BufferLength);
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = malloc(StubMsg.BufferLength);
StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength;
ptr = NdrComplexStructMarshall(&StubMsg, (unsigned char *)memsrc, fmtstr);
@ -1267,8 +1266,8 @@ static void test_struct_align(void)
ok(!memcmp(mem, memsrc, sizeof(*memsrc)), "struct wasn't unmarshalled correctly\n");
StubMsg.pfnFree(mem);
heap_free(StubMsg.RpcMsg->Buffer);
heap_free(memsrc_orig);
free(StubMsg.RpcMsg->Buffer);
free(memsrc_orig);
}
struct testiface
@ -1360,7 +1359,7 @@ static void test_iface_ptr(void)
StubMsg.BufferLength = 0;
NdrInterfacePointerBufferSize(&StubMsg, (unsigned char *)&client_obj.IPersist_iface, fmtstr_ip);
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = malloc(StubMsg.BufferLength);
StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength;
/* server -> client */
@ -1540,7 +1539,7 @@ static void test_iface_ptr(void)
NdrInterfacePointerFree(&StubMsg, (unsigned char *)proxy, fmtstr_ip);
ok(client_obj.ref == 1, "got %ld references\n", client_obj.ref);
HeapFree(GetProcessHeap(), 0, StubMsg.BufferStart);
free(StubMsg.BufferStart);
CoUninitialize();
}
@ -1948,7 +1947,7 @@ static void test_conformant_array(void)
ok(StubMsg.BufferLength >= 20, "length %ld\n", StubMsg.BufferLength);
/*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = malloc(StubMsg.BufferLength);
StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength;
ptr = NdrConformantArrayMarshall( &StubMsg, memsrc, fmtstr_conf_array );
@ -2022,7 +2021,7 @@ static void test_conformant_array(void)
StubMsg.pfnFree(mem);
StubMsg.pfnFree(mem_orig);
HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer);
free(StubMsg.RpcMsg->Buffer);
}
static void test_conformant_string(void)
@ -2059,7 +2058,7 @@ static void test_conformant_string(void)
ok(StubMsg.BufferLength >= sizeof(memsrc) + 12, "length %ld\n", StubMsg.BufferLength);
/*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = malloc(StubMsg.BufferLength);
StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength;
ptr = NdrPointerMarshall( &StubMsg, (unsigned char *)memsrc, fmtstr_conf_str );
@ -2076,7 +2075,7 @@ static void test_conformant_string(void)
/* Client */
my_alloc_called = 0;
StubMsg.Buffer = StubMsg.BufferStart;
mem = mem_orig = HeapAlloc(GetProcessHeap(), 0, sizeof(memsrc));
mem = mem_orig = malloc(sizeof(memsrc));
/* Windows apparently checks string length on the output buffer to determine its size... */
memset( mem, 'x', sizeof(memsrc) - 1 );
mem[sizeof(memsrc) - 1] = 0;
@ -2093,7 +2092,7 @@ static void test_conformant_string(void)
/* Prevent a memory leak when running with Wine.
Remove once the todo_wine block above is fixed. */
if (mem != mem_orig)
HeapFree(GetProcessHeap(), 0, mem_orig);
free(mem_orig);
my_free_called = 0;
StubMsg.Buffer = StubMsg.BufferStart;
@ -2125,7 +2124,7 @@ static void test_conformant_string(void)
ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
my_alloc_called = 0;
mem = mem_orig = HeapAlloc(GetProcessHeap(), 0, sizeof(memsrc));
mem = mem_orig = malloc(sizeof(memsrc));
StubMsg.Buffer = StubMsg.BufferStart;
NdrPointerUnmarshall( &StubMsg, &mem, fmtstr_conf_str, 0);
ok(mem == StubMsg.BufferStart + 12 || broken(!mem), /* win9x, nt4 */
@ -2146,8 +2145,8 @@ static void test_conformant_string(void)
NdrPointerFree( &StubMsg, mem, fmtstr_conf_str );
ok(my_free_called == 1, "free called %d\n", my_free_called);
HeapFree(GetProcessHeap(), 0, mem_orig);
HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer);
free(mem_orig);
free(StubMsg.RpcMsg->Buffer);
}
static void test_nonconformant_string(void)
@ -2184,7 +2183,7 @@ static void test_nonconformant_string(void)
ok(StubMsg.BufferLength >= strlen((char *)memsrc) + 1 + 8, "length %ld\n", StubMsg.BufferLength);
/*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = malloc(StubMsg.BufferLength);
StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength;
ptr = NdrNonConformantStringMarshall( &StubMsg, memsrc, fmtstr_nonconf_str );
@ -2201,7 +2200,7 @@ static void test_nonconformant_string(void)
/* Client */
my_alloc_called = 0;
StubMsg.Buffer = StubMsg.BufferStart;
mem = mem_orig = HeapAlloc(GetProcessHeap(), 0, sizeof(memsrc));
mem = mem_orig = malloc(sizeof(memsrc));
NdrNonConformantStringUnmarshall( &StubMsg, &mem, fmtstr_nonconf_str, 0);
ok(mem == mem_orig, "mem alloced\n");
ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
@ -2241,8 +2240,8 @@ static void test_nonconformant_string(void)
todo_wine
ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
HeapFree(GetProcessHeap(), 0, mem_orig);
HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer);
free(mem_orig);
free(StubMsg.RpcMsg->Buffer);
/* length = size */
NdrClientInitializeNew(
@ -2257,7 +2256,7 @@ static void test_nonconformant_string(void)
ok(StubMsg.BufferLength >= strlen((char *)memsrc2) + 1 + 8, "length %ld\n", StubMsg.BufferLength);
/*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = malloc(StubMsg.BufferLength);
StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength;
ptr = NdrNonConformantStringMarshall( &StubMsg, memsrc2, fmtstr_nonconf_str );
@ -2274,7 +2273,7 @@ static void test_nonconformant_string(void)
/* Client */
my_alloc_called = 0;
StubMsg.Buffer = StubMsg.BufferStart;
mem = mem_orig = HeapAlloc(GetProcessHeap(), 0, sizeof(memsrc));
mem = mem_orig = malloc(sizeof(memsrc));
NdrNonConformantStringUnmarshall( &StubMsg, &mem, fmtstr_nonconf_str, 0);
ok(mem == mem_orig, "mem alloced\n");
ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
@ -2314,8 +2313,8 @@ static void test_nonconformant_string(void)
todo_wine
ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
HeapFree(GetProcessHeap(), 0, mem_orig);
HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer);
free(mem_orig);
free(StubMsg.RpcMsg->Buffer);
}
static void test_conf_complex_struct(void)
@ -2366,8 +2365,7 @@ static void test_conf_complex_struct(void)
0x5b, /* FC_END */
};
memsrc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
FIELD_OFFSET(struct conf_complex, array[20]));
memsrc = calloc(1, FIELD_OFFSET(struct conf_complex, array[20]));
memsrc->size = 20;
StubDesc = Object_StubDesc;
@ -2384,7 +2382,7 @@ static void test_conf_complex_struct(void)
ok(StubMsg.BufferLength >= 92, "length %ld\n", StubMsg.BufferLength);
/*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = malloc(StubMsg.BufferLength);
StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength;
ptr = NdrComplexStructMarshall(&StubMsg, (unsigned char *)memsrc, &fmtstr_complex_struct[12]);
@ -2410,8 +2408,8 @@ static void test_conf_complex_struct(void)
ok(mem->array[0] == 0, "mem->array[0] wasn't unmarshalled correctly (%u)\n", mem->array[0]);
StubMsg.pfnFree(mem);
HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer);
HeapFree(GetProcessHeap(), 0, memsrc);
free(StubMsg.RpcMsg->Buffer);
free(memsrc);
}
@ -2493,11 +2491,11 @@ static void test_conf_complex_array(void)
memsrc.dim1 = 5;
memsrc.dim2 = 3;
memsrc.array = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, memsrc.dim1 * sizeof(DWORD*));
memsrc.array = calloc(memsrc.dim1, sizeof(DWORD *));
for(i = 0; i < memsrc.dim1; i++)
{
memsrc.array[i] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, memsrc.dim2 * sizeof(DWORD));
memsrc.array[i] = calloc(memsrc.dim2, sizeof(DWORD));
for(j = 0; j < memsrc.dim2; j++)
memsrc.array[i][j] = i * memsrc.dim2 + j;
}
@ -2527,7 +2525,7 @@ static void test_conf_complex_array(void)
ok(StubMsg.BufferLength >= expected_length, "length %ld\n", StubMsg.BufferLength);
/*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = malloc(StubMsg.BufferLength);
StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength;
#ifdef _WIN64
@ -2591,11 +2589,11 @@ static void test_conf_complex_array(void)
NdrSimpleStructFree( &StubMsg, (unsigned char*)mem, &fmtstr_complex_array[32]);
#endif
HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer);
free(StubMsg.RpcMsg->Buffer);
for(i = 0; i < memsrc.dim1; i++)
HeapFree(GetProcessHeap(), 0, memsrc.array[i]);
HeapFree(GetProcessHeap(), 0, memsrc.array);
free(memsrc.array[i]);
free(memsrc.array);
}
static void test_ndr_buffer(void)

View file

@ -913,7 +913,7 @@ static void test_RpcServerInqDefaultPrincName(void)
ULONG len = 0;
GetUserNameExA( NameSamCompatible, NULL, &len );
username = HeapAlloc( GetProcessHeap(), 0, len );
username = malloc( len );
GetUserNameExA( NameSamCompatible, username, &len );
ret = RpcServerInqDefaultPrincNameA( 0, NULL );
@ -948,7 +948,7 @@ static void test_RpcServerInqDefaultPrincName(void)
ok( ret == RPC_S_OK, "got %lu\n", ret );
RpcStringFreeA( &saved_principal );
HeapFree( GetProcessHeap(), 0, username );
free( username );
}
static void test_RpcServerRegisterAuthInfo(void)

View file

@ -285,21 +285,13 @@ static void InitFunctionPointers(void)
void __RPC_FAR *__RPC_USER
midl_user_allocate(SIZE_T n)
{
return HeapAlloc(GetProcessHeap(), 0, n);
return malloc(n);
}
void __RPC_USER
midl_user_free(void __RPC_FAR *p)
{
HeapFree(GetProcessHeap(), 0, p);
}
static char *
xstrdup(const char *s)
{
char *d = HeapAlloc(GetProcessHeap(), 0, strlen(s) + 1);
strcpy(d, s);
return d;
free(p);
}
int __cdecl s_int_return(void)
@ -801,7 +793,7 @@ void __cdecl s_get_a_bstr(bstr_t *b)
{
bstr_t bstr;
short str[] = {5, 'W', 'i', 'n', 'e', 0};
bstr = HeapAlloc(GetProcessHeap(), 0, sizeof(str));
bstr = malloc(sizeof(str));
memcpy(bstr, str, sizeof(str));
*b = bstr + 1;
}
@ -1490,7 +1482,7 @@ union_tests(void)
static test_list_t *
null_list(void)
{
test_list_t *n = HeapAlloc(GetProcessHeap(), 0, sizeof *n);
test_list_t *n = malloc(sizeof *n);
n->t = TL_NULL;
n->u.x = 0;
return n;
@ -1499,7 +1491,7 @@ null_list(void)
static test_list_t *
make_list(test_list_t *tail)
{
test_list_t *n = HeapAlloc(GetProcessHeap(), 0, sizeof *n);
test_list_t *n = malloc(sizeof *n);
n->t = TL_LIST;
n->u.tail = tail;
return n;
@ -1510,7 +1502,7 @@ free_list(test_list_t *list)
{
if (list->t == TL_LIST)
free_list(list->u.tail);
HeapFree(GetProcessHeap(), 0, list);
free(list);
}
ULONG __RPC_USER
@ -1532,7 +1524,7 @@ puint_t_UserUnmarshal(ULONG *flags, unsigned char *buffer, puint_t *p)
{
int n;
memcpy(&n, buffer, sizeof n);
*p = HeapAlloc(GetProcessHeap(), 0, 10);
*p = malloc(10);
sprintf(*p, "%d", n);
return buffer + sizeof n;
}
@ -1540,7 +1532,7 @@ puint_t_UserUnmarshal(ULONG *flags, unsigned char *buffer, puint_t *p)
void __RPC_USER
puint_t_UserFree(ULONG *flags, puint_t *p)
{
HeapFree(GetProcessHeap(), 0, *p);
free(*p);
}
ULONG __RPC_USER
@ -1563,7 +1555,7 @@ us_t_UserUnmarshal(ULONG *flags, unsigned char *buffer, us_t *pus)
{
struct wire_us wus;
memcpy(&wus, buffer, sizeof wus);
pus->x = HeapAlloc(GetProcessHeap(), 0, 10);
pus->x = malloc(10);
sprintf(pus->x, "%d", wus.x);
return buffer + sizeof wus;
}
@ -1571,7 +1563,7 @@ us_t_UserUnmarshal(ULONG *flags, unsigned char *buffer, us_t *pus)
void __RPC_USER
us_t_UserFree(ULONG *flags, us_t *pus)
{
HeapFree(GetProcessHeap(), 0, pus->x);
free(pus->x);
}
ULONG __RPC_USER
@ -1593,7 +1585,7 @@ unsigned char * __RPC_USER
bstr_t_UserUnmarshal(ULONG *flags, unsigned char *buffer, bstr_t *b)
{
wire_bstr_t wb = (wire_bstr_t) buffer;
short *data = HeapAlloc(GetProcessHeap(), 0, (wb->n + 1) * sizeof *data);
short *data = malloc((wb->n + 1) * sizeof *data);
data[0] = wb->n;
memcpy(&data[1], wb->data, wb->n * sizeof data[1]);
*b = &data[1];
@ -1603,7 +1595,7 @@ bstr_t_UserUnmarshal(ULONG *flags, unsigned char *buffer, bstr_t *b)
void __RPC_USER
bstr_t_UserFree(ULONG *flags, bstr_t *b)
{
HeapFree(GetProcessHeap(), 0, &((*b)[-1]));
free(&((*b)[-1]));
}
static void
@ -1627,29 +1619,29 @@ pointer_tests(void)
ok(test_list_length(list) == 3, "RPC test_list_length\n");
ok(square_puint(p1) == 121, "RPC square_puint\n");
pus.n = 4;
pus.ps = HeapAlloc(GetProcessHeap(), 0, pus.n * sizeof pus.ps[0]);
pus.ps[0] = xstrdup("5");
pus.ps[1] = xstrdup("6");
pus.ps[2] = xstrdup("7");
pus.ps[3] = xstrdup("8");
pus.ps = malloc(pus.n * sizeof pus.ps[0]);
pus.ps[0] = strdup("5");
pus.ps[1] = strdup("6");
pus.ps[2] = strdup("7");
pus.ps[3] = strdup("8");
ok(sum_puints(&pus) == 26, "RPC sum_puints\n");
HeapFree(GetProcessHeap(), 0, pus.ps[0]);
HeapFree(GetProcessHeap(), 0, pus.ps[1]);
HeapFree(GetProcessHeap(), 0, pus.ps[2]);
HeapFree(GetProcessHeap(), 0, pus.ps[3]);
HeapFree(GetProcessHeap(), 0, pus.ps);
free(pus.ps[0]);
free(pus.ps[1]);
free(pus.ps[2]);
free(pus.ps[3]);
free(pus.ps);
cpus.n = 4;
cpus.ps = HeapAlloc(GetProcessHeap(), 0, cpus.n * sizeof cpus.ps[0]);
cpus.ps[0] = xstrdup("5");
cpus.ps[1] = xstrdup("6");
cpus.ps[2] = xstrdup("7");
cpus.ps[3] = xstrdup("8");
cpus.ps = malloc(cpus.n * sizeof cpus.ps[0]);
cpus.ps[0] = strdup("5");
cpus.ps[1] = strdup("6");
cpus.ps[2] = strdup("7");
cpus.ps[3] = strdup("8");
ok(sum_cpuints(&cpus) == 26, "RPC sum_puints\n");
HeapFree(GetProcessHeap(), 0, cpus.ps[0]);
HeapFree(GetProcessHeap(), 0, cpus.ps[1]);
HeapFree(GetProcessHeap(), 0, cpus.ps[2]);
HeapFree(GetProcessHeap(), 0, cpus.ps[3]);
HeapFree(GetProcessHeap(), 0, cpus.ps);
free(cpus.ps[0]);
free(cpus.ps[1]);
free(cpus.ps[2]);
free(cpus.ps[3]);
free(cpus.ps);
ok(square_test_us(&tus) == 121, "RPC square_test_us\n");
pa[0] = &a[0];
@ -1668,8 +1660,8 @@ pointer_tests(void)
get_a_bstr(&bstr);
s_get_a_bstr(&bstr2);
ok(!lstrcmpW((LPCWSTR)bstr, (LPCWSTR)bstr2), "bstr mismatch\n");
HeapFree(GetProcessHeap(), 0, bstr - 1);
HeapFree(GetProcessHeap(), 0, bstr2 - 1);
free(bstr - 1);
free(bstr2 - 1);
free_list(list);
@ -1680,11 +1672,11 @@ pointer_tests(void)
wstr_array_t namesw;
name.size = 10;
name.name = buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, name.size);
name.name = buffer = calloc(1, name.size);
get_name(&name);
ok(name.name == buffer, "[in,out] pointer should have stayed as %p but instead changed to %p\n", name.name, buffer);
ok(!strcmp(name.name, "Jeremy Wh"), "name didn't unmarshall properly, expected \"Jeremy Wh\", but got \"%s\"\n", name.name);
HeapFree(GetProcessHeap(), 0, name.name);
free(name.name);
if (!is_interp) { /* broken in widl */
n = -1;
@ -1803,7 +1795,7 @@ array_tests(void)
ok(sum_var_array(&c[2], 0) == 0, "RPC sum_conf_array\n");
ok(dot_two_vectors(vs) == -4, "RPC dot_two_vectors\n");
cs = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(cs_t, ca[5]));
cs = malloc(FIELD_OFFSET(cs_t, ca[5]));
cs->n = 5;
cs->ca[0] = 3;
cs->ca[1] = 5;
@ -1811,7 +1803,7 @@ array_tests(void)
cs->ca[3] = -1;
cs->ca[4] = -4;
ok(sum_cs(cs) == 1, "RPC sum_cs\n");
HeapFree(GetProcessHeap(), 0, cs);
free(cs);
n = 5;
cps.pn = &n;
@ -1847,21 +1839,21 @@ array_tests(void)
ok(sum_toplev_conf_cond(c, 5, 6, 1) == 10, "RPC sum_toplev_conf_cond\n");
ok(sum_toplev_conf_cond(c, 5, 6, 0) == 15, "RPC sum_toplev_conf_cond\n");
dc = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(doub_carr_t, a[2]));
dc = malloc(FIELD_OFFSET(doub_carr_t, a[2]));
dc->n = 2;
dc->a[0] = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(doub_carr_1_t, a[3]));
dc->a[0] = malloc(sizeof(doub_carr_1_t) + 3);
dc->a[0]->n = 3;
dc->a[0]->a[0] = 5;
dc->a[0]->a[1] = 1;
dc->a[0]->a[2] = 8;
dc->a[1] = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(doub_carr_1_t, a[2]));
dc->a[1] = malloc(sizeof(doub_carr_1_t) + 2);
dc->a[1]->n = 2;
dc->a[1]->a[0] = 2;
dc->a[1]->a[1] = 3;
ok(sum_doub_carr(dc) == 19, "RPC sum_doub_carr\n");
HeapFree(GetProcessHeap(), 0, dc->a[0]);
HeapFree(GetProcessHeap(), 0, dc->a[1]);
HeapFree(GetProcessHeap(), 0, dc);
free(dc->a[0]);
free(dc->a[1]);
free(dc);
dc = NULL;
make_pyramid_doub_carr(4, &dc);
@ -1871,7 +1863,7 @@ array_tests(void)
ok(sum_L1_norms(2, vs) == 21, "RPC sum_L1_norms\n");
memset(api, 0, sizeof(api));
pi = HeapAlloc(GetProcessHeap(), 0, sizeof(*pi));
pi = malloc(sizeof(*pi));
*pi = -1;
api[0].pi = pi;
get_numbers(1, 1, api);
@ -1880,25 +1872,25 @@ array_tests(void)
if (!old_windows_version)
{
ns = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(numbers_struct_t, numbers[5]));
ns = calloc(1, FIELD_OFFSET(numbers_struct_t, numbers[5]));
ns->length = 5;
ns->size = 5;
ns->numbers[0].pi = pi;
get_numbers_struct(&ns);
ok(ns->numbers[0].pi == pi, "RPC conformant varying struct embedded pointer changed from %p to %p\n", pi, ns->numbers[0].pi);
ok(*ns->numbers[0].pi == 5, "pi unmarshalled incorrectly %d\n", *ns->numbers[0].pi);
HeapFree(GetProcessHeap(), 0, ns);
free(ns);
}
HeapFree(GetProcessHeap(), 0, pi);
free(pi);
pi = HeapAlloc(GetProcessHeap(), 0, 5 * sizeof(*pi));
pi = malloc(5 * sizeof(*pi));
pi[0] = 3; rpi[0] = &pi[0];
pi[1] = 5; rpi[1] = &pi[1];
pi[2] = -2; rpi[2] = &pi[2];
pi[3] = -1; rpi[3] = &pi[3];
pi[4] = -4; rpi[4] = &pi[4];
ok(sum_complex_array(5, rpi) == 1, "RPC sum_complex_array\n");
HeapFree(GetProcessHeap(), 0, pi);
free(pi);
ok(sum_ptr_array(ptr_array) == 3, "RPC sum_ptr_array\n");
ok(sum_array_ptr(&array) == 7, "RPC sum_array_ptr\n");
@ -1956,11 +1948,11 @@ void __cdecl s_authinfo_test(unsigned int protseq, int secure)
char *spn;
len = WideCharToMultiByte(CP_ACP, 0, (const WCHAR *)privs, -1, NULL, 0, NULL, NULL);
spn = HeapAlloc( GetProcessHeap(), 0, len );
spn = malloc(len);
WideCharToMultiByte(CP_ACP, 0, (const WCHAR *)privs, -1, spn, len, NULL, NULL);
ok(!strcmp(domain_and_user, spn), "expected %s got %s\n", domain_and_user, spn);
HeapFree( GetProcessHeap(), 0, spn );
free(spn);
}
ok(level == RPC_C_AUTHN_LEVEL_PKT_PRIVACY, "level unchanged\n");
ok(authnsvc == RPC_C_AUTHN_WINNT, "authnsvc unchanged\n");
@ -2709,7 +2701,7 @@ START_TEST(server)
set_mixed_interface();
ok(!GetUserNameExA(NameSamCompatible, NULL, &size), "GetUserNameExA\n");
domain_and_user = HeapAlloc(GetProcessHeap(), 0, size);
domain_and_user = malloc(size);
ok(GetUserNameExA(NameSamCompatible, domain_and_user, &size), "GetUserNameExA\n");
argc = winetest_get_mainargs(&argv);
@ -2775,5 +2767,5 @@ START_TEST(server)
if (firewall_disabled) set_firewall(APP_REMOVE);
}
HeapFree(GetProcessHeap(), 0, domain_and_user);
free(domain_and_user);
}