winetest: Rename xmalloc() & co to heap_xxx() to not imply they are based on malloc(), and add heap_free().
diff --git a/programs/winetest/gui.c b/programs/winetest/gui.c
index 2957dbf..a2b1e7f 100644
--- a/programs/winetest/gui.c
+++ b/programs/winetest/gui.c
@@ -66,7 +66,7 @@
fputs (str, stderr);
fputc ('\n', stderr);
- free (str);
+ heap_free (str);
return 0;
}
@@ -78,7 +78,7 @@
if (len > 128) str[129] = 0;
SetDlgItemText (dialog, IDC_SB, str);
- free (str);
+ heap_free (str);
return 0;
}
@@ -121,7 +121,7 @@
progressCurr++;
fputs (str, stderr);
fprintf (stderr, " (%d of %d)\n", progressCurr, progressMax);
- free (str);
+ heap_free (str);
return 0;
}
@@ -135,7 +135,7 @@
SetDlgItemText (dialog, pgID, str);
SendDlgItemMessage (dialog, pgID+1, PBM_SETPOS,
(WPARAM)(progressScale * progressCurr), 0);
- free (str);
+ heap_free (str);
return 0;
}
@@ -149,7 +149,7 @@
progressCurr += inc;
fputs (str, stderr);
fprintf (stderr, " (%d of %d)\n", progressCurr, progressMax);
- free (str);
+ heap_free (str);
return 0;
}
@@ -164,7 +164,7 @@
SetDlgItemText (dialog, pgID, str);
SendDlgItemMessage (dialog, pgID+1, PBM_SETPOS,
(WPARAM)(progressScale * progressCurr), 0);
- free (str);
+ heap_free (str);
return 0;
}
@@ -194,7 +194,7 @@
fputs ("Temporary directory: ", stderr);
fputs (str, stderr);
fputc ('\n', stderr);
- free (str);
+ heap_free (str);
return 0;
}
@@ -204,7 +204,7 @@
char *str = vstrmake (NULL, ap);
SetDlgItemText (dialog, IDC_DIR, str);
- free (str);
+ heap_free (str);
return 0;
}
@@ -217,7 +217,7 @@
fputs ("Log file: ", stderr);
fputs (str, stderr);
fputc ('\n', stderr);
- free (str);
+ heap_free (str);
return 0;
}
@@ -227,7 +227,7 @@
char *str = vstrmake (NULL, ap);
SetDlgItemText (dialog, IDC_OUT, str);
- free (str);
+ heap_free (str);
return 0;
}
@@ -246,7 +246,7 @@
char *str = vstrmake (NULL, ap);
MessageBox (dialog, str, "Warning", MB_ICONWARNING | MB_OK);
- free (str);
+ heap_free (str);
return 0;
}
@@ -265,7 +265,7 @@
char *str = vstrmake (NULL, ap);
MessageBox (dialog, str, "Error", MB_ICONERROR | MB_OK);
- free (str);
+ heap_free (str);
return 0;
}
@@ -294,7 +294,7 @@
fprintf (stderr, "Question of type %d: %s\n"
"Returning default: %d\n", uType, str, ret);
- free (str);
+ heap_free (str);
return ret;
}
@@ -306,7 +306,7 @@
int ret = MessageBox (dialog, str, "Question",
MB_ICONQUESTION | uType);
- free (str);
+ heap_free (str);
return ret;
}
@@ -341,7 +341,7 @@
report (R_WARNING, "You must enter a tag to continue");
return FALSE;
}
- tag = xmalloc (len+1);
+ tag = heap_alloc (len+1);
GetDlgItemTextA (hwnd, IDC_TAG, tag, len+1);
EndDialog (hwnd, IDOK);
return TRUE;
diff --git a/programs/winetest/main.c b/programs/winetest/main.c
index 7bbb0cb..69496bd 100644
--- a/programs/winetest/main.c
+++ b/programs/winetest/main.c
@@ -98,7 +98,7 @@
size = GetFileVersionInfoSizeA(file_name, &handle);
if (size) {
- char * data = xmalloc(size);
+ char * data = heap_alloc(size);
if (data) {
if (GetFileVersionInfoA(file_name, handle, size, data)) {
static char backslash[] = "\\";
@@ -114,7 +114,7 @@
sprintf(version, "version not available");
} else
sprintf(version, "unknown");
- free(data);
+ heap_free(data);
} else
sprintf(version, "failed");
} else
@@ -311,12 +311,12 @@
code = extract_rcdata (res_name, TESTRES, &size);
if (!code) report (R_FATAL, "Can't find test resource %s: %d",
res_name, GetLastError ());
- test->name = xstrdup( res_name );
+ test->name = heap_strdup( res_name );
test->exename = strmake (NULL, "%s\\%s", dir, test->name);
exepos = strstr (test->name, testexe);
if (!exepos) report (R_FATAL, "Not an .exe file: %s", test->name);
*exepos = 0;
- test->name = xrealloc (test->name, exepos - test->name + 1);
+ test->name = heap_realloc (test->name, exepos - test->name + 1);
report (R_STEP, "Extracting: %s", test->name);
hfile = CreateFileA(test->exename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
@@ -349,13 +349,13 @@
{
char *newpath;
- newpath = xmalloc(strlen(curpath) + 1 + strlen(path) + 1);
+ newpath = heap_alloc(strlen(curpath) + 1 + strlen(path) + 1);
strcpy(newpath, curpath);
strcat(newpath, ";");
strcat(newpath, path);
SetEnvironmentVariableA("PATH", newpath);
- free(newpath);
+ heap_free(newpath);
}
/* Run a command for MS milliseconds. If OUT != NULL, also redirect
@@ -473,7 +473,7 @@
/* Restore PATH again */
SetEnvironmentVariableA("PATH", curpath);
}
- free (cmd);
+ heap_free (cmd);
if (status == -2)
{
@@ -502,20 +502,20 @@
index += sizeof header;
allocated = 10;
- test->subtests = xmalloc (allocated * sizeof(char*));
+ test->subtests = heap_alloc (allocated * sizeof(char*));
index = strtok (index, whitespace);
while (index) {
if (test->subtest_count == allocated) {
allocated *= 2;
- test->subtests = xrealloc (test->subtests,
- allocated * sizeof(char*));
+ test->subtests = heap_realloc (test->subtests,
+ allocated * sizeof(char*));
}
if (!test_filtered_out( test->name, index ))
- test->subtests[test->subtest_count++] = xstrdup(index);
+ test->subtests[test->subtest_count++] = heap_strdup(index);
index = strtok (NULL, whitespace);
}
- test->subtests = xrealloc (test->subtests,
- test->subtest_count * sizeof(char*));
+ test->subtests = heap_realloc (test->subtests,
+ test->subtest_count * sizeof(char*));
err = 0;
quit:
@@ -533,7 +533,7 @@
xprintf ("%s:%s start %s -\n", test->name, subtest, file);
status = run_ex (cmd, out_file, tempdir, 120000);
- free (cmd);
+ heap_free (cmd);
xprintf ("%s:%s done (%d)\n", test->name, subtest, status);
}
@@ -583,7 +583,7 @@
GetModuleFileNameA(dll, dllpath, MAX_PATH);
strcpy(filename, dllpath);
*strrchr(dllpath, '\\') = '\0';
- wine_tests[nr_of_files].maindllpath = xstrdup( dllpath );
+ wine_tests[nr_of_files].maindllpath = heap_strdup( dllpath );
}
}
if (!dll) {
@@ -623,7 +623,7 @@
/* Get the current PATH only once */
needed = GetEnvironmentVariableA("PATH", NULL, 0);
- curpath = xmalloc(needed);
+ curpath = heap_alloc(needed);
GetEnvironmentVariableA("PATH", curpath, needed);
SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
@@ -702,7 +702,7 @@
EnumTestFileProc, (LPARAM)&nr_of_files))
report (R_FATAL, "Can't enumerate test files: %d",
GetLastError ());
- wine_tests = xmalloc (nr_of_files * sizeof wine_tests[0]);
+ wine_tests = heap_alloc (nr_of_files * sizeof wine_tests[0]);
/* Do this only once during extraction (and version checking) */
hmscoree = LoadLibraryA("mscoree.dll");
@@ -753,8 +753,8 @@
CloseHandle( logfile );
logfile = 0;
remove_dir (tempdir);
- free (wine_tests);
- free (curpath);
+ heap_free(wine_tests);
+ heap_free(curpath);
return logname;
}
@@ -800,7 +800,7 @@
if (!EnumResourceNames (NULL, MAKEINTRESOURCE(TESTRES), EnumTestFileProc, (LPARAM)&nr_of_files))
report (R_FATAL, "Can't enumerate test files: %d", GetLastError ());
- wine_tests = xmalloc (nr_of_files * sizeof wine_tests[0] );
+ wine_tests = heap_alloc (nr_of_files * sizeof wine_tests[0] );
report (R_STATUS, "Extracting tests");
report (R_PROGRESS, 0, nr_of_files);
diff --git a/programs/winetest/send.c b/programs/winetest/send.c
index 947f2c1..9eae079 100644
--- a/programs/winetest/send.c
+++ b/programs/winetest/send.c
@@ -97,7 +97,7 @@
va_end (ap);
if (!p) return 1;
ret = send_buf (s, p, len);
- free (p);
+ heap_free (p);
return ret;
}
@@ -159,7 +159,7 @@
str = strmake (&total, body1, name);
ret = send_str (s, head, filesize + total + sizeof body2 - 1) ||
send_buf (s, str, total);
- free (str);
+ heap_free (str);
if (ret) {
report (R_WARNING, "Error sending header: %d, %d",
errno, WSAGetLastError ());
@@ -211,7 +211,7 @@
str = strmake (&count, "Received %s (%d bytes).\n",
name, filesize);
ret = memcmp (str, buffer + total - count, count);
- free (str);
+ heap_free (str);
if (ret) {
buffer[total] = 0;
str = strstr (buffer, "\r\n\r\n");
diff --git a/programs/winetest/util.c b/programs/winetest/util.c
index 0253296..66f79f5 100644
--- a/programs/winetest/util.c
+++ b/programs/winetest/util.c
@@ -27,7 +27,7 @@
HANDLE logfile = 0;
-void *xmalloc (size_t len)
+void *heap_alloc (size_t len)
{
void *p = malloc (len);
@@ -35,7 +35,7 @@
return p;
}
-void *xrealloc (void *op, size_t len)
+void *heap_realloc (void *op, size_t len)
{
void *p = realloc (op, len);
@@ -43,13 +43,18 @@
return p;
}
-char *xstrdup( const char *str )
+char *heap_strdup( const char *str )
{
char *res = strdup( str );
if (!res) report (R_FATAL, "Out of memory.");
return res;
}
+void heap_free (void *op)
+{
+ free (op);
+}
+
static char *vstrfmtmake (size_t *lenp, const char *fmt, va_list ap)
{
size_t size = 1000;
@@ -65,7 +70,7 @@
else break;
q = realloc (p, size);
if (!q) {
- free (p);
+ heap_free (p);
return NULL;
}
p = q;
@@ -111,7 +116,7 @@
head += written;
size -= written;
}
- free (buffer);
+ heap_free (buffer);
}
int
diff --git a/programs/winetest/winetest.h b/programs/winetest/winetest.h
index e4844a9..945586c 100644
--- a/programs/winetest/winetest.h
+++ b/programs/winetest/winetest.h
@@ -45,9 +45,10 @@
#ifndef __WINE_ALLOC_SIZE
#define __WINE_ALLOC_SIZE(x)
#endif
-void *xmalloc (size_t len) __WINE_ALLOC_SIZE(1);
-void *xrealloc (void *op, size_t len) __WINE_ALLOC_SIZE(2);
-char *xstrdup( const char *str );
+void *heap_alloc (size_t len) __WINE_ALLOC_SIZE(1);
+void *heap_realloc (void *op, size_t len) __WINE_ALLOC_SIZE(2);
+char *heap_strdup( const char *str );
+void heap_free (void *op);
enum report_type {
R_STATUS = 0,