Commit 22aceb44 authored by Alexandre Julliard's avatar Alexandre Julliard

winetest: Use CRT allocation functions.

parent b4a5556d
...@@ -66,7 +66,7 @@ textStatus (va_list ap) ...@@ -66,7 +66,7 @@ textStatus (va_list ap)
fputs (str, stderr); fputs (str, stderr);
fputc ('\n', stderr); fputc ('\n', stderr);
heap_free (str); free(str);
return 0; return 0;
} }
...@@ -78,7 +78,7 @@ guiStatus (va_list ap) ...@@ -78,7 +78,7 @@ guiStatus (va_list ap)
if (len > 128) str[129] = 0; if (len > 128) str[129] = 0;
SetDlgItemTextA (dialog, IDC_SB, str); SetDlgItemTextA (dialog, IDC_SB, str);
heap_free (str); free(str);
return 0; return 0;
} }
...@@ -121,7 +121,7 @@ textStep (va_list ap) ...@@ -121,7 +121,7 @@ textStep (va_list ap)
progressCurr++; progressCurr++;
fputs (str, stderr); fputs (str, stderr);
fprintf (stderr, " (%d of %d)\n", progressCurr, progressMax); fprintf (stderr, " (%d of %d)\n", progressCurr, progressMax);
heap_free (str); free(str);
return 0; return 0;
} }
...@@ -135,7 +135,7 @@ guiStep (va_list ap) ...@@ -135,7 +135,7 @@ guiStep (va_list ap)
SetDlgItemTextA (dialog, pgID, str); SetDlgItemTextA (dialog, pgID, str);
SendDlgItemMessageA(dialog, pgID+1, PBM_SETPOS, SendDlgItemMessageA(dialog, pgID+1, PBM_SETPOS,
progressScale * progressCurr, 0); progressScale * progressCurr, 0);
heap_free (str); free(str);
return 0; return 0;
} }
...@@ -149,7 +149,7 @@ textDelta (va_list ap) ...@@ -149,7 +149,7 @@ textDelta (va_list ap)
progressCurr += inc; progressCurr += inc;
fputs (str, stderr); fputs (str, stderr);
fprintf (stderr, " (%d of %d)\n", progressCurr, progressMax); fprintf (stderr, " (%d of %d)\n", progressCurr, progressMax);
heap_free (str); free(str);
return 0; return 0;
} }
...@@ -164,7 +164,7 @@ guiDelta (va_list ap) ...@@ -164,7 +164,7 @@ guiDelta (va_list ap)
SetDlgItemTextA (dialog, pgID, str); SetDlgItemTextA (dialog, pgID, str);
SendDlgItemMessageA(dialog, pgID+1, PBM_SETPOS, SendDlgItemMessageA(dialog, pgID+1, PBM_SETPOS,
progressScale * progressCurr, 0); progressScale * progressCurr, 0);
heap_free (str); free(str);
return 0; return 0;
} }
...@@ -194,7 +194,7 @@ textDir (va_list ap) ...@@ -194,7 +194,7 @@ textDir (va_list ap)
fputs ("Temporary directory: ", stderr); fputs ("Temporary directory: ", stderr);
fputs (str, stderr); fputs (str, stderr);
fputc ('\n', stderr); fputc ('\n', stderr);
heap_free (str); free(str);
return 0; return 0;
} }
...@@ -204,7 +204,7 @@ guiDir (va_list ap) ...@@ -204,7 +204,7 @@ guiDir (va_list ap)
char *str = vstrmake (NULL, ap); char *str = vstrmake (NULL, ap);
SetDlgItemTextA (dialog, IDC_DIR, str); SetDlgItemTextA (dialog, IDC_DIR, str);
heap_free (str); free(str);
return 0; return 0;
} }
...@@ -217,7 +217,7 @@ textOut (va_list ap) ...@@ -217,7 +217,7 @@ textOut (va_list ap)
fputs ("Log file: ", stderr); fputs ("Log file: ", stderr);
fputs (str, stderr); fputs (str, stderr);
fputc ('\n', stderr); fputc ('\n', stderr);
heap_free (str); free(str);
return 0; return 0;
} }
...@@ -227,7 +227,7 @@ guiOut (va_list ap) ...@@ -227,7 +227,7 @@ guiOut (va_list ap)
char *str = vstrmake (NULL, ap); char *str = vstrmake (NULL, ap);
SetDlgItemTextA (dialog, IDC_OUT, str); SetDlgItemTextA (dialog, IDC_OUT, str);
heap_free (str); free(str);
return 0; return 0;
} }
...@@ -246,7 +246,7 @@ guiWarning (va_list ap) ...@@ -246,7 +246,7 @@ guiWarning (va_list ap)
char *str = vstrmake (NULL, ap); char *str = vstrmake (NULL, ap);
MessageBoxA (dialog, str, "Warning", MB_ICONWARNING | MB_OK); MessageBoxA (dialog, str, "Warning", MB_ICONWARNING | MB_OK);
heap_free (str); free(str);
return 0; return 0;
} }
...@@ -265,7 +265,7 @@ guiError (va_list ap) ...@@ -265,7 +265,7 @@ guiError (va_list ap)
char *str = vstrmake (NULL, ap); char *str = vstrmake (NULL, ap);
MessageBoxA (dialog, str, "Error", MB_ICONERROR | MB_OK); MessageBoxA (dialog, str, "Error", MB_ICONERROR | MB_OK);
heap_free (str); free(str);
return 0; return 0;
} }
...@@ -296,7 +296,7 @@ textAsk (va_list ap) ...@@ -296,7 +296,7 @@ textAsk (va_list ap)
fprintf (stderr, "Question of type %d: %s\n" fprintf (stderr, "Question of type %d: %s\n"
"Returning default: %d\n", uType, str, ret); "Returning default: %d\n", uType, str, ret);
heap_free (str); free(str);
return ret; return ret;
} }
...@@ -307,7 +307,7 @@ guiAsk (va_list ap) ...@@ -307,7 +307,7 @@ guiAsk (va_list ap)
char *str = vstrmake (NULL, ap); char *str = vstrmake (NULL, ap);
int ret = MessageBoxA (dialog, str, "Question", MB_ICONQUESTION | uType); int ret = MessageBoxA (dialog, str, "Question", MB_ICONQUESTION | uType);
heap_free (str); free(str);
return ret; return ret;
} }
...@@ -342,7 +342,7 @@ AskTagProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -342,7 +342,7 @@ AskTagProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
report (R_WARNING, "You must enter a tag to continue"); report (R_WARNING, "You must enter a tag to continue");
return FALSE; return FALSE;
} }
tag = heap_alloc (len+1); tag = xalloc(len+1);
GetDlgItemTextA (hwnd, IDC_TAG, tag, len+1); GetDlgItemTextA (hwnd, IDC_TAG, tag, len+1);
EndDialog (hwnd, IDOK); EndDialog (hwnd, IDOK);
return TRUE; return TRUE;
...@@ -375,7 +375,7 @@ AskEmailProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -375,7 +375,7 @@ AskEmailProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
report (R_WARNING, "You must enter an email address to continue"); report (R_WARNING, "You must enter an email address to continue");
return FALSE; return FALSE;
} }
email = heap_alloc (len+1); email = xalloc(len+1);
GetDlgItemTextA (hwnd, IDC_EMAIL, email, len+1); GetDlgItemTextA (hwnd, IDC_EMAIL, email, len+1);
EndDialog (hwnd, IDOK); EndDialog (hwnd, IDOK);
return TRUE; return TRUE;
......
...@@ -117,25 +117,22 @@ static char * get_file_version(char * file_name) ...@@ -117,25 +117,22 @@ static char * get_file_version(char * file_name)
size = GetFileVersionInfoSizeA(file_name, &handle); size = GetFileVersionInfoSizeA(file_name, &handle);
if (size) { if (size) {
char * data = heap_alloc(size); char * data = xalloc(size);
if (data) { if (GetFileVersionInfoA(file_name, handle, size, data)) {
if (GetFileVersionInfoA(file_name, handle, size, data)) { static const char backslash[] = "\\";
static const char backslash[] = "\\"; VS_FIXEDFILEINFO *pFixedVersionInfo;
VS_FIXEDFILEINFO *pFixedVersionInfo; UINT len;
UINT len; if (VerQueryValueA(data, backslash, (LPVOID *)&pFixedVersionInfo, &len)) {
if (VerQueryValueA(data, backslash, (LPVOID *)&pFixedVersionInfo, &len)) { sprintf(version, "%ld.%ld.%ld.%ld",
sprintf(version, "%ld.%ld.%ld.%ld", pFixedVersionInfo->dwFileVersionMS >> 16,
pFixedVersionInfo->dwFileVersionMS >> 16, pFixedVersionInfo->dwFileVersionMS & 0xffff,
pFixedVersionInfo->dwFileVersionMS & 0xffff, pFixedVersionInfo->dwFileVersionLS >> 16,
pFixedVersionInfo->dwFileVersionLS >> 16, pFixedVersionInfo->dwFileVersionLS & 0xffff);
pFixedVersionInfo->dwFileVersionLS & 0xffff);
} else
sprintf(version, "version not found");
} else } else
sprintf(version, "version error %lu", GetLastError()); sprintf(version, "version not found");
heap_free(data);
} else } else
sprintf(version, "version error %u", ERROR_OUTOFMEMORY); sprintf(version, "version error %lu", GetLastError());
free(data);
} else if (GetLastError() == ERROR_FILE_NOT_FOUND) } else if (GetLastError() == ERROR_FILE_NOT_FOUND)
sprintf(version, "dll is missing"); sprintf(version, "dll is missing");
else else
...@@ -237,16 +234,10 @@ static int running_as_admin (void) ...@@ -237,16 +234,10 @@ static int running_as_admin (void)
/* Get the group info from the token */ /* Get the group info from the token */
groups_size = 0; groups_size = 0;
GetTokenInformation(token, TokenGroups, NULL, 0, &groups_size); GetTokenInformation(token, TokenGroups, NULL, 0, &groups_size);
groups = heap_alloc(groups_size); groups = xalloc(groups_size);
if (groups == NULL)
{
CloseHandle(token);
FreeSid(administrators);
return -1;
}
if (! GetTokenInformation(token, TokenGroups, groups, groups_size, &groups_size)) if (! GetTokenInformation(token, TokenGroups, groups, groups_size, &groups_size))
{ {
heap_free(groups); free(groups);
CloseHandle(token); CloseHandle(token);
FreeSid(administrators); FreeSid(administrators);
return -1; return -1;
...@@ -258,14 +249,14 @@ static int running_as_admin (void) ...@@ -258,14 +249,14 @@ static int running_as_admin (void)
{ {
if (EqualSid(groups->Groups[group_index].Sid, administrators)) if (EqualSid(groups->Groups[group_index].Sid, administrators))
{ {
heap_free(groups); free(groups);
FreeSid(administrators); FreeSid(administrators);
return 1; return 1;
} }
} }
/* If we end up here we didn't find the Administrators group */ /* If we end up here we didn't find the Administrators group */
heap_free(groups); free(groups);
FreeSid(administrators); FreeSid(administrators);
return 0; return 0;
} }
...@@ -326,9 +317,7 @@ static BOOL is_stub_dll(const char *filename) ...@@ -326,9 +317,7 @@ static BOOL is_stub_dll(const char *filename)
size = GetFileVersionInfoSizeA(filename, &ver); size = GetFileVersionInfoSizeA(filename, &ver);
if (!size) return FALSE; if (!size) return FALSE;
data = HeapAlloc(GetProcessHeap(), 0, size); data = xalloc(size);
if (!data) return FALSE;
if (GetFileVersionInfoA(filename, ver, size, data)) if (GetFileVersionInfoA(filename, ver, size, data))
{ {
char buf[256]; char buf[256];
...@@ -337,7 +326,7 @@ static BOOL is_stub_dll(const char *filename) ...@@ -337,7 +326,7 @@ static BOOL is_stub_dll(const char *filename)
if (VerQueryValueA(data, buf, (void**)&p, &size)) if (VerQueryValueA(data, buf, (void**)&p, &size))
isstub = !lstrcmpiA("wcodstub.dll", p); isstub = !lstrcmpiA("wcodstub.dll", p);
} }
HeapFree(GetProcessHeap(), 0, data); free(data);
return isstub; return isstub;
} }
...@@ -561,12 +550,12 @@ extract_test (struct wine_test *test, const char *dir, LPSTR res_name) ...@@ -561,12 +550,12 @@ extract_test (struct wine_test *test, const char *dir, LPSTR res_name)
code = extract_rcdata (res_name, "TESTRES", &size); code = extract_rcdata (res_name, "TESTRES", &size);
if (!code) report (R_FATAL, "Can't find test resource %s: %d", if (!code) report (R_FATAL, "Can't find test resource %s: %d",
res_name, GetLastError ()); res_name, GetLastError ());
test->name = heap_strdup( res_name ); test->name = xstrdup( res_name );
test->exename = strmake (NULL, "%s\\%s", dir, test->name); test->exename = strmake (NULL, "%s\\%s", dir, test->name);
exepos = strstr (test->name, testexe); exepos = strstr (test->name, testexe);
if (!exepos) report (R_FATAL, "Not an .exe file: %s", test->name); if (!exepos) report (R_FATAL, "Not an .exe file: %s", test->name);
*exepos = 0; *exepos = 0;
test->name = heap_realloc (test->name, exepos - test->name + 1); test->name = xrealloc(test->name, exepos - test->name + 1);
report (R_STEP, "Extracting: %s", test->name); report (R_STEP, "Extracting: %s", test->name);
hfile = CreateFileA(test->exename, GENERIC_READ | GENERIC_WRITE, 0, NULL, hfile = CreateFileA(test->exename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
...@@ -597,15 +586,9 @@ static DWORD wait_process( HANDLE process, DWORD timeout ) ...@@ -597,15 +586,9 @@ static DWORD wait_process( HANDLE process, DWORD timeout )
static void append_path( const char *path) static void append_path( const char *path)
{ {
char *newpath; char *newpath = strmake( NULL, "%s;%s", curpath, path );
newpath = heap_alloc(strlen(curpath) + 1 + strlen(path) + 1);
strcpy(newpath, curpath);
strcat(newpath, ";");
strcat(newpath, path);
SetEnvironmentVariableA("PATH", newpath); SetEnvironmentVariableA("PATH", newpath);
free(newpath);
heap_free(newpath);
} }
/* Run a command for MS milliseconds. If OUT != NULL, also redirect /* Run a command for MS milliseconds. If OUT != NULL, also redirect
...@@ -740,7 +723,7 @@ get_subtests (const char *tempdir, struct wine_test *test, LPSTR res_name) ...@@ -740,7 +723,7 @@ get_subtests (const char *tempdir, struct wine_test *test, LPSTR res_name)
/* Restore PATH again */ /* Restore PATH again */
SetEnvironmentVariableA("PATH", curpath); SetEnvironmentVariableA("PATH", curpath);
} }
heap_free (cmd); free(cmd);
if (status) if (status)
{ {
...@@ -773,19 +756,17 @@ get_subtests (const char *tempdir, struct wine_test *test, LPSTR res_name) ...@@ -773,19 +756,17 @@ get_subtests (const char *tempdir, struct wine_test *test, LPSTR res_name)
index += sizeof header; index += sizeof header;
allocated = 10; allocated = 10;
test->subtests = heap_alloc (allocated * sizeof(char*)); test->subtests = xalloc(allocated * sizeof(char*));
index = strtok (index, whitespace); index = strtok (index, whitespace);
while (index) { while (index) {
if (test->subtest_count == allocated) { if (test->subtest_count == allocated) {
allocated *= 2; allocated *= 2;
test->subtests = heap_realloc (test->subtests, test->subtests = xrealloc(test->subtests, allocated * sizeof(char*));
allocated * sizeof(char*));
} }
test->subtests[test->subtest_count++] = heap_strdup(index); test->subtests[test->subtest_count++] = xstrdup(index);
index = strtok (NULL, whitespace); index = strtok (NULL, whitespace);
} }
test->subtests = heap_realloc (test->subtests, test->subtests = xrealloc(test->subtests, test->subtest_count * sizeof(char*));
test->subtest_count * sizeof(char*));
err = 0; err = 0;
quit: quit:
...@@ -815,7 +796,7 @@ run_test (struct wine_test* test, const char* subtest, HANDLE out_file, const ch ...@@ -815,7 +796,7 @@ run_test (struct wine_test* test, const char* subtest, HANDLE out_file, const ch
xprintf ("%s:%s start %s\n", test->name, subtest, file); xprintf ("%s:%s start %s\n", test->name, subtest, file);
status = run_ex (cmd, out_file, tempdir, 120000, FALSE, &pid); status = run_ex (cmd, out_file, tempdir, 120000, FALSE, &pid);
if (status == -2) status = -GetLastError(); if (status == -2) status = -GetLastError();
heap_free (cmd); free(cmd);
xprintf ("%s:%s:%04x done (%d) in %ds\n", test->name, subtest, pid, status, (GetTickCount()-start)/1000); xprintf ("%s:%s:%04x done (%d) in %ds\n", test->name, subtest, pid, status, (GetTickCount()-start)/1000);
if (status) failures++; if (status) failures++;
} }
...@@ -882,7 +863,7 @@ static HMODULE load_com_dll(const char *name, char **path, char *filename) ...@@ -882,7 +863,7 @@ static HMODULE load_com_dll(const char *name, char **path, char *filename)
strcpy( filename, dllname ); strcpy( filename, dllname );
p = strrchr(dllname, '\\'); p = strrchr(dllname, '\\');
if (p) *p = 0; if (p) *p = 0;
*path = heap_strdup( dllname ); *path = xstrdup( dllname );
} }
} }
RegCloseKey(hkey); RegCloseKey(hkey);
...@@ -898,7 +879,7 @@ static void get_dll_path(HMODULE dll, char **path, char *filename) ...@@ -898,7 +879,7 @@ static void get_dll_path(HMODULE dll, char **path, char *filename)
GetModuleFileNameA(dll, dllpath, MAX_PATH); GetModuleFileNameA(dll, dllpath, MAX_PATH);
strcpy(filename, dllpath); strcpy(filename, dllpath);
*strrchr(dllpath, '\\') = '\0'; *strrchr(dllpath, '\\') = '\0';
*path = heap_strdup( dllpath ); *path = xstrdup( dllpath );
} }
static BOOL CALLBACK static BOOL CALLBACK
...@@ -1033,7 +1014,7 @@ run_tests (char *logname, char *outdir) ...@@ -1033,7 +1014,7 @@ run_tests (char *logname, char *outdir)
/* Get the current PATH only once */ /* Get the current PATH only once */
needed = GetEnvironmentVariableA("PATH", NULL, 0); needed = GetEnvironmentVariableA("PATH", NULL, 0);
curpath = heap_alloc(needed); curpath = xalloc(needed);
GetEnvironmentVariableA("PATH", curpath, needed); GetEnvironmentVariableA("PATH", curpath, needed);
SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
...@@ -1120,7 +1101,7 @@ run_tests (char *logname, char *outdir) ...@@ -1120,7 +1101,7 @@ run_tests (char *logname, char *outdir)
if (!EnumResourceNamesA (NULL, "TESTRES", EnumTestFileProc, (LPARAM)&nr_of_files)) if (!EnumResourceNamesA (NULL, "TESTRES", EnumTestFileProc, (LPARAM)&nr_of_files))
report (R_FATAL, "Can't enumerate test files: %d", report (R_FATAL, "Can't enumerate test files: %d",
GetLastError ()); GetLastError ());
wine_tests = heap_alloc (nr_of_files * sizeof wine_tests[0]); wine_tests = xalloc(nr_of_files * sizeof wine_tests[0]);
/* Do this only once during extraction (and version checking) */ /* Do this only once during extraction (and version checking) */
hmscoree = LoadLibraryA("mscoree.dll"); hmscoree = LoadLibraryA("mscoree.dll");
...@@ -1183,8 +1164,8 @@ run_tests (char *logname, char *outdir) ...@@ -1183,8 +1164,8 @@ run_tests (char *logname, char *outdir)
logfile = 0; logfile = 0;
if (newdir) if (newdir)
remove_dir (tempdir); remove_dir (tempdir);
heap_free(wine_tests); free(wine_tests);
heap_free(curpath); free(curpath);
return logname; return logname;
} }
...@@ -1230,7 +1211,7 @@ static void extract_only (const char *target_dir) ...@@ -1230,7 +1211,7 @@ static void extract_only (const char *target_dir)
if (!EnumResourceNamesA(NULL, "TESTRES", EnumTestFileProc, (LPARAM)&nr_of_files)) if (!EnumResourceNamesA(NULL, "TESTRES", EnumTestFileProc, (LPARAM)&nr_of_files))
report (R_FATAL, "Can't enumerate test files: %d", GetLastError ()); report (R_FATAL, "Can't enumerate test files: %d", GetLastError ());
wine_tests = heap_alloc (nr_of_files * sizeof wine_tests[0] ); wine_tests = xalloc(nr_of_files * sizeof wine_tests[0] );
report (R_STATUS, "Extracting tests"); report (R_STATUS, "Extracting tests");
report (R_PROGRESS, 0, nr_of_files); report (R_PROGRESS, 0, nr_of_files);
......
...@@ -113,9 +113,8 @@ static int WINAPIV send_str (SOCKET s, ...) ...@@ -113,9 +113,8 @@ static int WINAPIV send_str (SOCKET s, ...)
va_start (ap, s); va_start (ap, s);
p = vstrmake (&len, ap); p = vstrmake (&len, ap);
va_end (ap); va_end (ap);
if (!p) return 1;
ret = send_buf (s, p, len); ret = send_buf (s, p, len);
heap_free (p); free(p);
return ret; return ret;
} }
...@@ -168,7 +167,7 @@ send_file_direct (const char * url, const char *name) ...@@ -168,7 +167,7 @@ send_file_direct (const char * url, const char *name)
str = strmake (&total, body1, name); str = strmake (&total, body1, name);
ret = send_str (s, head, filesize + total + sizeof body2 - 1) || ret = send_str (s, head, filesize + total + sizeof body2 - 1) ||
send_buf (s, str, total); send_buf (s, str, total);
heap_free (str); free(str);
if (ret) { if (ret) {
report (R_WARNING, "Error sending header: %d, %d", report (R_WARNING, "Error sending header: %d, %d",
errno, WSAGetLastError ()); errno, WSAGetLastError ());
...@@ -222,7 +221,7 @@ send_file_direct (const char * url, const char *name) ...@@ -222,7 +221,7 @@ send_file_direct (const char * url, const char *name)
str = strmake (&count, "Received %s (%d bytes).\n", str = strmake (&count, "Received %s (%d bytes).\n",
name, filesize); name, filesize);
ret = total < count || memcmp (str, buffer + total - count, count) != 0; ret = total < count || memcmp (str, buffer + total - count, count) != 0;
heap_free (str); free(str);
if (ret) { if (ret) {
buffer[total] = 0; buffer[total] = 0;
str = strstr (buffer, "\r\n\r\n"); str = strstr (buffer, "\r\n\r\n");
...@@ -291,12 +290,12 @@ send_file_wininet (const char *url, const char *name) ...@@ -291,12 +290,12 @@ send_file_wininet (const char *url, const char *name)
uc.dwSchemeLength = uc.dwHostNameLength = uc.dwUserNameLength = uc.dwSchemeLength = uc.dwHostNameLength = uc.dwUserNameLength =
uc.dwPasswordLength = uc.dwUrlPathLength = uc.dwExtraInfoLength = uc.dwPasswordLength = uc.dwUrlPathLength = uc.dwExtraInfoLength =
strlen(url) + 1; strlen(url) + 1;
uc.lpszScheme = heap_alloc (uc.dwSchemeLength); uc.lpszScheme = xalloc(uc.dwSchemeLength);
uc.lpszHostName = heap_alloc (uc.dwHostNameLength); uc.lpszHostName = xalloc(uc.dwHostNameLength);
uc.lpszUserName = heap_alloc (uc.dwUserNameLength); uc.lpszUserName = xalloc(uc.dwUserNameLength);
uc.lpszPassword = heap_alloc (uc.dwPasswordLength); uc.lpszPassword = xalloc(uc.dwPasswordLength);
uc.lpszUrlPath = heap_alloc (uc.dwUrlPathLength); uc.lpszUrlPath = xalloc(uc.dwUrlPathLength);
uc.lpszExtraInfo = heap_alloc (uc.dwExtraInfoLength); uc.lpszExtraInfo = xalloc(uc.dwExtraInfoLength);
if (!pInternetCrackUrlA(url, 0, 0, &uc)) { if (!pInternetCrackUrlA(url, 0, 0, &uc)) {
report (R_WARNING, "Can't parse submit URL '%s'", url); report (R_WARNING, "Can't parse submit URL '%s'", url);
goto done; goto done;
...@@ -308,11 +307,11 @@ send_file_wininet (const char *url, const char *name) ...@@ -308,11 +307,11 @@ send_file_wininet (const char *url, const char *name)
} else { } else {
uc.nScheme = INTERNET_SCHEME_HTTP; uc.nScheme = INTERNET_SCHEME_HTTP;
uc.lpszHostName = heap_strdup (SERVER_NAME); uc.lpszHostName = xstrdup(SERVER_NAME);
uc.nPort = INTERNET_DEFAULT_HTTP_PORT; uc.nPort = INTERNET_DEFAULT_HTTP_PORT;
uc.lpszUserName = heap_strdup (""); uc.lpszUserName = xstrdup("");
uc.lpszPassword = heap_strdup (""); uc.lpszPassword = xstrdup("");
uc.lpszUrlPath = heap_strdup (URL_PATH); uc.lpszUrlPath = xstrdup(URL_PATH);
} }
ret = 1; ret = 1;
...@@ -412,7 +411,7 @@ send_file_wininet (const char *url, const char *name) ...@@ -412,7 +411,7 @@ send_file_wininet (const char *url, const char *name)
} }
while (bytes_read != 0); while (bytes_read != 0);
heap_free (str); free(str);
str = strmake (&count, "Received %s (%d bytes).\n", str = strmake (&count, "Received %s (%d bytes).\n",
name, filesize); name, filesize);
if (total < count || memcmp (str, buffer + total - count, count) != 0) { if (total < count || memcmp (str, buffer + total - count, count) != 0) {
...@@ -422,14 +421,14 @@ send_file_wininet (const char *url, const char *name) ...@@ -422,14 +421,14 @@ send_file_wininet (const char *url, const char *name)
} }
done: done:
heap_free (uc.lpszScheme); free(uc.lpszScheme);
heap_free (uc.lpszHostName); free(uc.lpszHostName);
heap_free (uc.lpszUserName); free(uc.lpszUserName);
heap_free (uc.lpszPassword); free(uc.lpszPassword);
heap_free (uc.lpszUrlPath); free(uc.lpszUrlPath);
heap_free (uc.lpszExtraInfo); free(uc.lpszExtraInfo);
heap_free((void *)buffers_in.lpcszHeader); free((void *)buffers_in.lpcszHeader);
heap_free(str); free(str);
if (pInternetCloseHandle != NULL && request != NULL) if (pInternetCloseHandle != NULL && request != NULL)
pInternetCloseHandle (request); pInternetCloseHandle (request);
if (pInternetCloseHandle != NULL && connection != NULL) if (pInternetCloseHandle != NULL && connection != NULL)
......
...@@ -27,55 +27,42 @@ ...@@ -27,55 +27,42 @@
HANDLE logfile = 0; HANDLE logfile = 0;
void *heap_alloc (size_t len) void *xalloc (size_t len)
{ {
void *p = HeapAlloc(GetProcessHeap(), 0, len); void *p = malloc( len );
if (!p) report (R_FATAL, "Out of memory."); if (!p) report (R_FATAL, "Out of memory.");
return p; return p;
} }
void *heap_realloc (void *op, size_t len) void *xrealloc (void *op, size_t len)
{ {
void *p = HeapReAlloc(GetProcessHeap(), 0, op, len); void *p = realloc(op, len);
if (len && !p) report (R_FATAL, "Out of memory."); if (len && !p) report (R_FATAL, "Out of memory.");
return p; return p;
} }
char *heap_strdup( const char *str ) char *xstrdup( const char *str )
{ {
int len = strlen(str) + 1; char* res = strdup( str );
char* res = HeapAlloc(GetProcessHeap(), 0, len);
if (!res) report (R_FATAL, "Out of memory."); if (!res) report (R_FATAL, "Out of memory.");
memcpy(res, str, len);
return res; return res;
} }
void heap_free (void *op)
{
HeapFree(GetProcessHeap(), 0, op);
}
static char *vstrfmtmake (size_t *lenp, const char *fmt, va_list ap) static char *vstrfmtmake (size_t *lenp, const char *fmt, va_list ap)
{ {
size_t size = 1000; size_t size = 1000;
char *p, *q; char *p;
int n; int n;
p = HeapAlloc(GetProcessHeap(), 0, size); p = xalloc(size);
if (!p) return NULL;
while (1) { while (1) {
n = vsnprintf (p, size, fmt, ap); n = vsnprintf (p, size, fmt, ap);
if (n < 0) size *= 2; /* Windows */ if (n < 0) size *= 2; /* Windows */
else if ((unsigned)n >= size) size = n+1; /* glibc */ else if ((unsigned)n >= size) size = n+1; /* glibc */
else break; else break;
q = HeapReAlloc(GetProcessHeap(), 0, p, size); p = xrealloc(p, size);
if (!q) {
heap_free (p);
return NULL;
}
p = q;
} }
if (lenp) *lenp = n; if (lenp) *lenp = n;
return p; return p;
...@@ -96,7 +83,6 @@ char * WINAPIV strmake (size_t *lenp, ...) ...@@ -96,7 +83,6 @@ char * WINAPIV strmake (size_t *lenp, ...)
va_start (ap, lenp); va_start (ap, lenp);
p = vstrmake (lenp, ap); p = vstrmake (lenp, ap);
if (!p) report (R_FATAL, "Out of memory.");
va_end (ap); va_end (ap);
return p; return p;
} }
...@@ -118,7 +104,7 @@ void WINAPIV xprintf (const char *fmt, ...) ...@@ -118,7 +104,7 @@ void WINAPIV xprintf (const char *fmt, ...)
head += written; head += written;
size -= written; size -= written;
} }
heap_free (buffer); free(buffer);
} }
int int
......
...@@ -45,10 +45,9 @@ extern HANDLE logfile; ...@@ -45,10 +45,9 @@ extern HANDLE logfile;
#ifndef __WINE_ALLOC_SIZE #ifndef __WINE_ALLOC_SIZE
#define __WINE_ALLOC_SIZE(x) #define __WINE_ALLOC_SIZE(x)
#endif #endif
void *heap_alloc (size_t len) __WINE_ALLOC_SIZE(1); void *xalloc (size_t len) __WINE_ALLOC_SIZE(1);
void *heap_realloc (void *op, size_t len) __WINE_ALLOC_SIZE(2); void *xrealloc (void *op, size_t len) __WINE_ALLOC_SIZE(2);
char *heap_strdup( const char *str ); char *xstrdup( const char *str );
void heap_free (void *op);
enum report_type { enum report_type {
R_STATUS = 0, R_STATUS = 0,
......
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