From: Alex Henrie alexhenrie24@gmail.com
--- dlls/rpcrt4/tests/cstub.c | 7 +- dlls/rpcrt4/tests/ndr_marshall.c | 116 +++++++++++++++---------------- dlls/rpcrt4/tests/rpc.c | 4 +- dlls/rpcrt4/tests/server.c | 116 ++++++++++++++----------------- 4 files changed, 116 insertions(+), 127 deletions(-)
diff --git a/dlls/rpcrt4/tests/cstub.c b/dlls/rpcrt4/tests/cstub.c index 794d85744ef..266d34c3c7f 100644 --- a/dlls/rpcrt4/tests/cstub.c +++ b/dlls/rpcrt4/tests/cstub.c @@ -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;
diff --git a/dlls/rpcrt4/tests/ndr_marshall.c b/dlls/rpcrt4/tests/ndr_marshall.c index 1c684cd6f53..ba9ceaf18fb 100644 --- a/dlls/rpcrt4/tests/ndr_marshall.c +++ b/dlls/rpcrt4/tests/ndr_marshall.c @@ -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) diff --git a/dlls/rpcrt4/tests/rpc.c b/dlls/rpcrt4/tests/rpc.c index 2a3d43cfc2d..c2f6b945d97 100644 --- a/dlls/rpcrt4/tests/rpc.c +++ b/dlls/rpcrt4/tests/rpc.c @@ -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) diff --git a/dlls/rpcrt4/tests/server.c b/dlls/rpcrt4/tests/server.c index 8e87a468f86..4b3dbf05be1 100644 --- a/dlls/rpcrt4/tests/server.c +++ b/dlls/rpcrt4/tests/server.c @@ -284,21 +284,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) @@ -800,7 +792,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; } @@ -1465,7 +1457,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; @@ -1474,7 +1466,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; @@ -1485,7 +1477,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 @@ -1507,7 +1499,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; } @@ -1515,7 +1507,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 @@ -1538,7 +1530,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; } @@ -1546,7 +1538,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 @@ -1568,7 +1560,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]; @@ -1578,7 +1570,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 @@ -1602,29 +1594,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]; @@ -1643,8 +1635,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);
@@ -1655,11 +1647,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; @@ -1778,7 +1770,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; @@ -1786,7 +1778,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; @@ -1822,21 +1814,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(FIELD_OFFSET(doub_carr_1_t, a[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(FIELD_OFFSET(doub_carr_1_t, a[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); @@ -1846,7 +1838,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); @@ -1855,25 +1847,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"); @@ -1931,11 +1923,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"); @@ -2622,7 +2614,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); @@ -2688,5 +2680,5 @@ START_TEST(server) if (firewall_disabled) set_firewall(APP_REMOVE); }
- HeapFree(GetProcessHeap(), 0, domain_and_user); + free(domain_and_user); }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=139586
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
rpcrt4: 06cc:ndr_marshall: unhandled exception c0000005 at 77035D79
=== w7u_adm (32 bit report) ===
rpcrt4: 0848:ndr_marshall: unhandled exception c0000005 at 77955D79
=== w7u_el (32 bit report) ===
rpcrt4: 0a5c:ndr_marshall: unhandled exception c0000005 at 77395D96
=== w8 (32 bit report) ===
rpcrt4: 0c2c:ndr_marshall: unhandled exception c0000005 at 77A3988E
=== w8adm (32 bit report) ===
rpcrt4: 0aa0:ndr_marshall: unhandled exception c0000005 at 77B8988E
=== w864 (32 bit report) ===
rpcrt4: 0930:ndr_marshall: unhandled exception c0000005 at 76EF1C49
=== w1064v1507 (32 bit report) ===
rpcrt4: 0c3c:ndr_marshall: unhandled exception c0000005 at 77D0CDB9
=== w1064v1809 (32 bit report) ===
rpcrt4: 1e70:ndr_marshall: unhandled exception c0000005 at 77AB78C6
=== w1064_tsign (32 bit report) ===
rpcrt4: 1f00:ndr_marshall: unhandled exception c0000005 at 76EB40FD
=== w10pro64 (32 bit report) ===
rpcrt4: 0ad4:ndr_marshall: unhandled exception c0000005 at 7700401D
=== w10pro64_en_AE_u8 (32 bit report) ===
rpcrt4: 187c:ndr_marshall: unhandled exception c0000005 at 77B0401D
=== w11pro64 (32 bit report) ===
rpcrt4: 1894:ndr_marshall: unhandled exception c0000005 at 77BB80A9
=== w7pro64 (64 bit report) ===
Report validation errors: rpcrt4:ndr_marshall crashed (c0000374)
=== w864 (64 bit report) ===
Report validation errors: rpcrt4:ndr_marshall crashed (c0000374)
=== w1064v1507 (64 bit report) ===
Report validation errors: rpcrt4:ndr_marshall crashed (c0000374)
=== w1064v1809 (64 bit report) ===
Report validation errors: rpcrt4:ndr_marshall crashed (c0000374)
=== w1064_2qxl (64 bit report) ===
Report validation errors: rpcrt4:ndr_marshall crashed (c0000374)
=== w1064_adm (64 bit report) ===
Report validation errors: rpcrt4:ndr_marshall crashed (c0000374)
=== w1064_tsign (64 bit report) ===
Report validation errors: rpcrt4:ndr_marshall crashed (c0000374)
=== w10pro64 (64 bit report) ===
Report validation errors: rpcrt4:ndr_marshall crashed (c0000374)
=== w10pro64_ar (64 bit report) ===
Report validation errors: rpcrt4:ndr_marshall crashed (c0000374)
=== w10pro64_ja (64 bit report) ===
Report validation errors: rpcrt4:ndr_marshall crashed (c0000374)
=== w10pro64_zh_CN (64 bit report) ===
Report validation errors: rpcrt4:ndr_marshall crashed (c0000374)
=== w11pro64_amd (64 bit report) ===
Report validation errors: rpcrt4:ndr_marshall crashed (c0000374)