From 4a558538c8a1862a018fb98cf4880439243c89bc Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Sun, 17 May 2009 13:28:46 +0200 Subject: [PATCH] winetest: Replace malloc() & co with HeapAlloc(). --- programs/winetest/util.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/programs/winetest/util.c b/programs/winetest/util.c index 66f79f5b44c..d0776eaf72e 100644 --- a/programs/winetest/util.c +++ b/programs/winetest/util.c @@ -29,7 +29,7 @@ HANDLE logfile = 0; void *heap_alloc (size_t len) { - void *p = malloc (len); + void *p = HeapAlloc(GetProcessHeap(), 0, len); if (!p) report (R_FATAL, "Out of memory."); return p; @@ -37,7 +37,7 @@ void *heap_alloc (size_t len) void *heap_realloc (void *op, size_t len) { - void *p = realloc (op, len); + void *p = HeapReAlloc(GetProcessHeap(), 0, op, len); if (len && !p) report (R_FATAL, "Out of memory."); return p; @@ -45,14 +45,16 @@ void *heap_realloc (void *op, size_t len) char *heap_strdup( const char *str ) { - char *res = strdup( str ); + int len = lstrlen(str) + 1; + char* res = HeapAlloc(GetProcessHeap(), 0, len); if (!res) report (R_FATAL, "Out of memory."); + memcpy(res, str, len); return res; } void heap_free (void *op) { - free (op); + HeapFree(GetProcessHeap(), 0, op); } static char *vstrfmtmake (size_t *lenp, const char *fmt, va_list ap) @@ -61,14 +63,14 @@ static char *vstrfmtmake (size_t *lenp, const char *fmt, va_list ap) char *p, *q; int n; - p = malloc (size); + p = HeapAlloc(GetProcessHeap(), 0, size); if (!p) return NULL; while (1) { n = vsnprintf (p, size, fmt, ap); if (n < 0) size *= 2; /* Windows */ else if ((unsigned)n >= size) size = n+1; /* glibc */ else break; - q = realloc (p, size); + q = HeapReAlloc(GetProcessHeap(), 0, p, size); if (!q) { heap_free (p); return NULL;