Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
22aceb44
Commit
22aceb44
authored
Aug 16, 2022
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winetest: Use CRT allocation functions.
parent
b4a5556d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
123 deletions
+88
-123
gui.c
programs/winetest/gui.c
+16
-16
main.c
programs/winetest/main.c
+37
-56
send.c
programs/winetest/send.c
+22
-23
util.c
programs/winetest/util.c
+10
-24
winetest.h
programs/winetest/winetest.h
+3
-4
No files found.
programs/winetest/gui.c
View file @
22aceb44
...
...
@@ -66,7 +66,7 @@ textStatus (va_list ap)
fputs
(
str
,
stderr
);
fputc
(
'\n'
,
stderr
);
heap_free
(
str
);
free
(
str
);
return
0
;
}
...
...
@@ -78,7 +78,7 @@ guiStatus (va_list ap)
if
(
len
>
128
)
str
[
129
]
=
0
;
SetDlgItemTextA
(
dialog
,
IDC_SB
,
str
);
heap_free
(
str
);
free
(
str
);
return
0
;
}
...
...
@@ -121,7 +121,7 @@ textStep (va_list ap)
progressCurr
++
;
fputs
(
str
,
stderr
);
fprintf
(
stderr
,
" (%d of %d)
\n
"
,
progressCurr
,
progressMax
);
heap_free
(
str
);
free
(
str
);
return
0
;
}
...
...
@@ -135,7 +135,7 @@ guiStep (va_list ap)
SetDlgItemTextA
(
dialog
,
pgID
,
str
);
SendDlgItemMessageA
(
dialog
,
pgID
+
1
,
PBM_SETPOS
,
progressScale
*
progressCurr
,
0
);
heap_free
(
str
);
free
(
str
);
return
0
;
}
...
...
@@ -149,7 +149,7 @@ textDelta (va_list ap)
progressCurr
+=
inc
;
fputs
(
str
,
stderr
);
fprintf
(
stderr
,
" (%d of %d)
\n
"
,
progressCurr
,
progressMax
);
heap_free
(
str
);
free
(
str
);
return
0
;
}
...
...
@@ -164,7 +164,7 @@ guiDelta (va_list ap)
SetDlgItemTextA
(
dialog
,
pgID
,
str
);
SendDlgItemMessageA
(
dialog
,
pgID
+
1
,
PBM_SETPOS
,
progressScale
*
progressCurr
,
0
);
heap_free
(
str
);
free
(
str
);
return
0
;
}
...
...
@@ -194,7 +194,7 @@ textDir (va_list ap)
fputs
(
"Temporary directory: "
,
stderr
);
fputs
(
str
,
stderr
);
fputc
(
'\n'
,
stderr
);
heap_free
(
str
);
free
(
str
);
return
0
;
}
...
...
@@ -204,7 +204,7 @@ guiDir (va_list ap)
char
*
str
=
vstrmake
(
NULL
,
ap
);
SetDlgItemTextA
(
dialog
,
IDC_DIR
,
str
);
heap_free
(
str
);
free
(
str
);
return
0
;
}
...
...
@@ -217,7 +217,7 @@ textOut (va_list ap)
fputs
(
"Log file: "
,
stderr
);
fputs
(
str
,
stderr
);
fputc
(
'\n'
,
stderr
);
heap_free
(
str
);
free
(
str
);
return
0
;
}
...
...
@@ -227,7 +227,7 @@ guiOut (va_list ap)
char
*
str
=
vstrmake
(
NULL
,
ap
);
SetDlgItemTextA
(
dialog
,
IDC_OUT
,
str
);
heap_free
(
str
);
free
(
str
);
return
0
;
}
...
...
@@ -246,7 +246,7 @@ guiWarning (va_list ap)
char
*
str
=
vstrmake
(
NULL
,
ap
);
MessageBoxA
(
dialog
,
str
,
"Warning"
,
MB_ICONWARNING
|
MB_OK
);
heap_free
(
str
);
free
(
str
);
return
0
;
}
...
...
@@ -265,7 +265,7 @@ guiError (va_list ap)
char
*
str
=
vstrmake
(
NULL
,
ap
);
MessageBoxA
(
dialog
,
str
,
"Error"
,
MB_ICONERROR
|
MB_OK
);
heap_free
(
str
);
free
(
str
);
return
0
;
}
...
...
@@ -296,7 +296,7 @@ textAsk (va_list ap)
fprintf
(
stderr
,
"Question of type %d: %s
\n
"
"Returning default: %d
\n
"
,
uType
,
str
,
ret
);
heap_free
(
str
);
free
(
str
);
return
ret
;
}
...
...
@@ -307,7 +307,7 @@ guiAsk (va_list ap)
char
*
str
=
vstrmake
(
NULL
,
ap
);
int
ret
=
MessageBoxA
(
dialog
,
str
,
"Question"
,
MB_ICONQUESTION
|
uType
);
heap_free
(
str
);
free
(
str
);
return
ret
;
}
...
...
@@ -342,7 +342,7 @@ AskTagProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
report
(
R_WARNING
,
"You must enter a tag to continue"
);
return
FALSE
;
}
tag
=
heap_alloc
(
len
+
1
);
tag
=
xalloc
(
len
+
1
);
GetDlgItemTextA
(
hwnd
,
IDC_TAG
,
tag
,
len
+
1
);
EndDialog
(
hwnd
,
IDOK
);
return
TRUE
;
...
...
@@ -375,7 +375,7 @@ AskEmailProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
report
(
R_WARNING
,
"You must enter an email address to continue"
);
return
FALSE
;
}
email
=
heap_alloc
(
len
+
1
);
email
=
xalloc
(
len
+
1
);
GetDlgItemTextA
(
hwnd
,
IDC_EMAIL
,
email
,
len
+
1
);
EndDialog
(
hwnd
,
IDOK
);
return
TRUE
;
...
...
programs/winetest/main.c
View file @
22aceb44
...
...
@@ -117,25 +117,22 @@ static char * get_file_version(char * file_name)
size
=
GetFileVersionInfoSizeA
(
file_name
,
&
handle
);
if
(
size
)
{
char
*
data
=
heap_alloc
(
size
);
if
(
data
)
{
if
(
GetFileVersionInfoA
(
file_name
,
handle
,
size
,
data
))
{
static
const
char
backslash
[]
=
"
\\
"
;
VS_FIXEDFILEINFO
*
pFixedVersionInfo
;
UINT
len
;
if
(
VerQueryValueA
(
data
,
backslash
,
(
LPVOID
*
)
&
pFixedVersionInfo
,
&
len
))
{
sprintf
(
version
,
"%ld.%ld.%ld.%ld"
,
pFixedVersionInfo
->
dwFileVersionMS
>>
16
,
pFixedVersionInfo
->
dwFileVersionMS
&
0xffff
,
pFixedVersionInfo
->
dwFileVersionLS
>>
16
,
pFixedVersionInfo
->
dwFileVersionLS
&
0xffff
);
}
else
sprintf
(
version
,
"version not found"
);
char
*
data
=
xalloc
(
size
);
if
(
GetFileVersionInfoA
(
file_name
,
handle
,
size
,
data
))
{
static
const
char
backslash
[]
=
"
\\
"
;
VS_FIXEDFILEINFO
*
pFixedVersionInfo
;
UINT
len
;
if
(
VerQueryValueA
(
data
,
backslash
,
(
LPVOID
*
)
&
pFixedVersionInfo
,
&
len
))
{
sprintf
(
version
,
"%ld.%ld.%ld.%ld"
,
pFixedVersionInfo
->
dwFileVersionMS
>>
16
,
pFixedVersionInfo
->
dwFileVersionMS
&
0xffff
,
pFixedVersionInfo
->
dwFileVersionLS
>>
16
,
pFixedVersionInfo
->
dwFileVersionLS
&
0xffff
);
}
else
sprintf
(
version
,
"version error %lu"
,
GetLastError
());
heap_free
(
data
);
sprintf
(
version
,
"version not found"
);
}
else
sprintf
(
version
,
"version error %u"
,
ERROR_OUTOFMEMORY
);
sprintf
(
version
,
"version error %lu"
,
GetLastError
());
free
(
data
);
}
else
if
(
GetLastError
()
==
ERROR_FILE_NOT_FOUND
)
sprintf
(
version
,
"dll is missing"
);
else
...
...
@@ -237,16 +234,10 @@ static int running_as_admin (void)
/* Get the group info from the token */
groups_size
=
0
;
GetTokenInformation
(
token
,
TokenGroups
,
NULL
,
0
,
&
groups_size
);
groups
=
heap_alloc
(
groups_size
);
if
(
groups
==
NULL
)
{
CloseHandle
(
token
);
FreeSid
(
administrators
);
return
-
1
;
}
groups
=
xalloc
(
groups_size
);
if
(
!
GetTokenInformation
(
token
,
TokenGroups
,
groups
,
groups_size
,
&
groups_size
))
{
heap_
free
(
groups
);
free
(
groups
);
CloseHandle
(
token
);
FreeSid
(
administrators
);
return
-
1
;
...
...
@@ -258,14 +249,14 @@ static int running_as_admin (void)
{
if
(
EqualSid
(
groups
->
Groups
[
group_index
].
Sid
,
administrators
))
{
heap_
free
(
groups
);
free
(
groups
);
FreeSid
(
administrators
);
return
1
;
}
}
/* If we end up here we didn't find the Administrators group */
heap_
free
(
groups
);
free
(
groups
);
FreeSid
(
administrators
);
return
0
;
}
...
...
@@ -326,9 +317,7 @@ static BOOL is_stub_dll(const char *filename)
size
=
GetFileVersionInfoSizeA
(
filename
,
&
ver
);
if
(
!
size
)
return
FALSE
;
data
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
if
(
!
data
)
return
FALSE
;
data
=
xalloc
(
size
);
if
(
GetFileVersionInfoA
(
filename
,
ver
,
size
,
data
))
{
char
buf
[
256
];
...
...
@@ -337,7 +326,7 @@ static BOOL is_stub_dll(const char *filename)
if
(
VerQueryValueA
(
data
,
buf
,
(
void
**
)
&
p
,
&
size
))
isstub
=
!
lstrcmpiA
(
"wcodstub.dll"
,
p
);
}
HeapFree
(
GetProcessHeap
(),
0
,
data
);
free
(
data
);
return
isstub
;
}
...
...
@@ -561,12 +550,12 @@ extract_test (struct wine_test *test, const char *dir, LPSTR res_name)
code
=
extract_rcdata
(
res_name
,
"TESTRES"
,
&
size
);
if
(
!
code
)
report
(
R_FATAL
,
"Can't find test resource %s: %d"
,
res_name
,
GetLastError
());
test
->
name
=
heap_
strdup
(
res_name
);
test
->
name
=
x
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
=
heap_realloc
(
test
->
name
,
exepos
-
test
->
name
+
1
);
test
->
name
=
xrealloc
(
test
->
name
,
exepos
-
test
->
name
+
1
);
report
(
R_STEP
,
"Extracting: %s"
,
test
->
name
);
hfile
=
CreateFileA
(
test
->
exename
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
...
...
@@ -597,15 +586,9 @@ static DWORD wait_process( HANDLE process, DWORD timeout )
static
void
append_path
(
const
char
*
path
)
{
char
*
newpath
;
newpath
=
heap_alloc
(
strlen
(
curpath
)
+
1
+
strlen
(
path
)
+
1
);
strcpy
(
newpath
,
curpath
);
strcat
(
newpath
,
";"
);
strcat
(
newpath
,
path
);
char
*
newpath
=
strmake
(
NULL
,
"%s;%s"
,
curpath
,
path
);
SetEnvironmentVariableA
(
"PATH"
,
newpath
);
heap_free
(
newpath
);
free
(
newpath
);
}
/* 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)
/* Restore PATH again */
SetEnvironmentVariableA
(
"PATH"
,
curpath
);
}
heap_free
(
cmd
);
free
(
cmd
);
if
(
status
)
{
...
...
@@ -773,19 +756,17 @@ get_subtests (const char *tempdir, struct wine_test *test, LPSTR res_name)
index
+=
sizeof
header
;
allocated
=
10
;
test
->
subtests
=
heap_alloc
(
allocated
*
sizeof
(
char
*
));
test
->
subtests
=
xalloc
(
allocated
*
sizeof
(
char
*
));
index
=
strtok
(
index
,
whitespace
);
while
(
index
)
{
if
(
test
->
subtest_count
==
allocated
)
{
allocated
*=
2
;
test
->
subtests
=
heap_realloc
(
test
->
subtests
,
allocated
*
sizeof
(
char
*
));
test
->
subtests
=
xrealloc
(
test
->
subtests
,
allocated
*
sizeof
(
char
*
));
}
test
->
subtests
[
test
->
subtest_count
++
]
=
heap_
strdup
(
index
);
test
->
subtests
[
test
->
subtest_count
++
]
=
x
strdup
(
index
);
index
=
strtok
(
NULL
,
whitespace
);
}
test
->
subtests
=
heap_realloc
(
test
->
subtests
,
test
->
subtest_count
*
sizeof
(
char
*
));
test
->
subtests
=
xrealloc
(
test
->
subtests
,
test
->
subtest_count
*
sizeof
(
char
*
));
err
=
0
;
quit:
...
...
@@ -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
);
status
=
run_ex
(
cmd
,
out_file
,
tempdir
,
120000
,
FALSE
,
&
pid
);
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
);
if
(
status
)
failures
++
;
}
...
...
@@ -882,7 +863,7 @@ static HMODULE load_com_dll(const char *name, char **path, char *filename)
strcpy
(
filename
,
dllname
);
p
=
strrchr
(
dllname
,
'\\'
);
if
(
p
)
*
p
=
0
;
*
path
=
heap_
strdup
(
dllname
);
*
path
=
x
strdup
(
dllname
);
}
}
RegCloseKey
(
hkey
);
...
...
@@ -898,7 +879,7 @@ static void get_dll_path(HMODULE dll, char **path, char *filename)
GetModuleFileNameA
(
dll
,
dllpath
,
MAX_PATH
);
strcpy
(
filename
,
dllpath
);
*
strrchr
(
dllpath
,
'\\'
)
=
'\0'
;
*
path
=
heap_
strdup
(
dllpath
);
*
path
=
x
strdup
(
dllpath
);
}
static
BOOL
CALLBACK
...
...
@@ -1033,7 +1014,7 @@ run_tests (char *logname, char *outdir)
/* Get the current PATH only once */
needed
=
GetEnvironmentVariableA
(
"PATH"
,
NULL
,
0
);
curpath
=
heap_
alloc
(
needed
);
curpath
=
x
alloc
(
needed
);
GetEnvironmentVariableA
(
"PATH"
,
curpath
,
needed
);
SetErrorMode
(
SEM_FAILCRITICALERRORS
|
SEM_NOGPFAULTERRORBOX
);
...
...
@@ -1120,7 +1101,7 @@ run_tests (char *logname, char *outdir)
if
(
!
EnumResourceNamesA
(
NULL
,
"TESTRES"
,
EnumTestFileProc
,
(
LPARAM
)
&
nr_of_files
))
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
]);
/* Do this only once during extraction (and version checking) */
hmscoree
=
LoadLibraryA
(
"mscoree.dll"
);
...
...
@@ -1183,8 +1164,8 @@ run_tests (char *logname, char *outdir)
logfile
=
0
;
if
(
newdir
)
remove_dir
(
tempdir
);
heap_
free
(
wine_tests
);
heap_
free
(
curpath
);
free
(
wine_tests
);
free
(
curpath
);
return
logname
;
}
...
...
@@ -1230,7 +1211,7 @@ static void extract_only (const char *target_dir)
if
(
!
EnumResourceNamesA
(
NULL
,
"TESTRES"
,
EnumTestFileProc
,
(
LPARAM
)
&
nr_of_files
))
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_PROGRESS
,
0
,
nr_of_files
);
...
...
programs/winetest/send.c
View file @
22aceb44
...
...
@@ -113,9 +113,8 @@ static int WINAPIV send_str (SOCKET s, ...)
va_start
(
ap
,
s
);
p
=
vstrmake
(
&
len
,
ap
);
va_end
(
ap
);
if
(
!
p
)
return
1
;
ret
=
send_buf
(
s
,
p
,
len
);
heap_free
(
p
);
free
(
p
);
return
ret
;
}
...
...
@@ -168,7 +167,7 @@ send_file_direct (const char * url, const char *name)
str
=
strmake
(
&
total
,
body1
,
name
);
ret
=
send_str
(
s
,
head
,
filesize
+
total
+
sizeof
body2
-
1
)
||
send_buf
(
s
,
str
,
total
);
heap_free
(
str
);
free
(
str
);
if
(
ret
)
{
report
(
R_WARNING
,
"Error sending header: %d, %d"
,
errno
,
WSAGetLastError
());
...
...
@@ -222,7 +221,7 @@ send_file_direct (const char * url, const char *name)
str
=
strmake
(
&
count
,
"Received %s (%d bytes).
\n
"
,
name
,
filesize
);
ret
=
total
<
count
||
memcmp
(
str
,
buffer
+
total
-
count
,
count
)
!=
0
;
heap_free
(
str
);
free
(
str
);
if
(
ret
)
{
buffer
[
total
]
=
0
;
str
=
strstr
(
buffer
,
"
\r\n\r\n
"
);
...
...
@@ -291,12 +290,12 @@ send_file_wininet (const char *url, const char *name)
uc
.
dwSchemeLength
=
uc
.
dwHostNameLength
=
uc
.
dwUserNameLength
=
uc
.
dwPasswordLength
=
uc
.
dwUrlPathLength
=
uc
.
dwExtraInfoLength
=
strlen
(
url
)
+
1
;
uc
.
lpszScheme
=
heap_alloc
(
uc
.
dwSchemeLength
);
uc
.
lpszHostName
=
heap_alloc
(
uc
.
dwHostNameLength
);
uc
.
lpszUserName
=
heap_alloc
(
uc
.
dwUserNameLength
);
uc
.
lpszPassword
=
heap_alloc
(
uc
.
dwPasswordLength
);
uc
.
lpszUrlPath
=
heap_alloc
(
uc
.
dwUrlPathLength
);
uc
.
lpszExtraInfo
=
heap_alloc
(
uc
.
dwExtraInfoLength
);
uc
.
lpszScheme
=
xalloc
(
uc
.
dwSchemeLength
);
uc
.
lpszHostName
=
xalloc
(
uc
.
dwHostNameLength
);
uc
.
lpszUserName
=
xalloc
(
uc
.
dwUserNameLength
);
uc
.
lpszPassword
=
xalloc
(
uc
.
dwPasswordLength
);
uc
.
lpszUrlPath
=
xalloc
(
uc
.
dwUrlPathLength
);
uc
.
lpszExtraInfo
=
xalloc
(
uc
.
dwExtraInfoLength
);
if
(
!
pInternetCrackUrlA
(
url
,
0
,
0
,
&
uc
))
{
report
(
R_WARNING
,
"Can't parse submit URL '%s'"
,
url
);
goto
done
;
...
...
@@ -308,11 +307,11 @@ send_file_wininet (const char *url, const char *name)
}
else
{
uc
.
nScheme
=
INTERNET_SCHEME_HTTP
;
uc
.
lpszHostName
=
heap_strdup
(
SERVER_NAME
);
uc
.
lpszHostName
=
xstrdup
(
SERVER_NAME
);
uc
.
nPort
=
INTERNET_DEFAULT_HTTP_PORT
;
uc
.
lpszUserName
=
heap_strdup
(
""
);
uc
.
lpszPassword
=
heap_strdup
(
""
);
uc
.
lpszUrlPath
=
heap_strdup
(
URL_PATH
);
uc
.
lpszUserName
=
xstrdup
(
""
);
uc
.
lpszPassword
=
xstrdup
(
""
);
uc
.
lpszUrlPath
=
xstrdup
(
URL_PATH
);
}
ret
=
1
;
...
...
@@ -412,7 +411,7 @@ send_file_wininet (const char *url, const char *name)
}
while
(
bytes_read
!=
0
);
heap_free
(
str
);
free
(
str
);
str
=
strmake
(
&
count
,
"Received %s (%d bytes).
\n
"
,
name
,
filesize
);
if
(
total
<
count
||
memcmp
(
str
,
buffer
+
total
-
count
,
count
)
!=
0
)
{
...
...
@@ -422,14 +421,14 @@ send_file_wininet (const char *url, const char *name)
}
done:
heap_free
(
uc
.
lpszScheme
);
heap_free
(
uc
.
lpszHostName
);
heap_free
(
uc
.
lpszUserName
);
heap_free
(
uc
.
lpszPassword
);
heap_free
(
uc
.
lpszUrlPath
);
heap_free
(
uc
.
lpszExtraInfo
);
heap_
free
((
void
*
)
buffers_in
.
lpcszHeader
);
heap_
free
(
str
);
free
(
uc
.
lpszScheme
);
free
(
uc
.
lpszHostName
);
free
(
uc
.
lpszUserName
);
free
(
uc
.
lpszPassword
);
free
(
uc
.
lpszUrlPath
);
free
(
uc
.
lpszExtraInfo
);
free
((
void
*
)
buffers_in
.
lpcszHeader
);
free
(
str
);
if
(
pInternetCloseHandle
!=
NULL
&&
request
!=
NULL
)
pInternetCloseHandle
(
request
);
if
(
pInternetCloseHandle
!=
NULL
&&
connection
!=
NULL
)
...
...
programs/winetest/util.c
View file @
22aceb44
...
...
@@ -27,55 +27,42 @@
HANDLE
logfile
=
0
;
void
*
heap_
alloc
(
size_t
len
)
void
*
x
alloc
(
size_t
len
)
{
void
*
p
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
void
*
p
=
malloc
(
len
);
if
(
!
p
)
report
(
R_FATAL
,
"Out of memory."
);
return
p
;
}
void
*
heap_
realloc
(
void
*
op
,
size_t
len
)
void
*
x
realloc
(
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."
);
return
p
;
}
char
*
heap_
strdup
(
const
char
*
str
)
char
*
x
strdup
(
const
char
*
str
)
{
int
len
=
strlen
(
str
)
+
1
;
char
*
res
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
char
*
res
=
strdup
(
str
);
if
(
!
res
)
report
(
R_FATAL
,
"Out of memory."
);
memcpy
(
res
,
str
,
len
);
return
res
;
}
void
heap_free
(
void
*
op
)
{
HeapFree
(
GetProcessHeap
(),
0
,
op
);
}
static
char
*
vstrfmtmake
(
size_t
*
lenp
,
const
char
*
fmt
,
va_list
ap
)
{
size_t
size
=
1000
;
char
*
p
,
*
q
;
char
*
p
;
int
n
;
p
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
if
(
!
p
)
return
NULL
;
p
=
xalloc
(
size
);
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
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
p
,
size
);
if
(
!
q
)
{
heap_free
(
p
);
return
NULL
;
}
p
=
q
;
p
=
xrealloc
(
p
,
size
);
}
if
(
lenp
)
*
lenp
=
n
;
return
p
;
...
...
@@ -96,7 +83,6 @@ char * WINAPIV strmake (size_t *lenp, ...)
va_start
(
ap
,
lenp
);
p
=
vstrmake
(
lenp
,
ap
);
if
(
!
p
)
report
(
R_FATAL
,
"Out of memory."
);
va_end
(
ap
);
return
p
;
}
...
...
@@ -118,7 +104,7 @@ void WINAPIV xprintf (const char *fmt, ...)
head
+=
written
;
size
-=
written
;
}
heap_free
(
buffer
);
free
(
buffer
);
}
int
...
...
programs/winetest/winetest.h
View file @
22aceb44
...
...
@@ -45,10 +45,9 @@ extern HANDLE logfile;
#ifndef __WINE_ALLOC_SIZE
#define __WINE_ALLOC_SIZE(x)
#endif
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
);
void
*
xalloc
(
size_t
len
)
__WINE_ALLOC_SIZE
(
1
);
void
*
xrealloc
(
void
*
op
,
size_t
len
)
__WINE_ALLOC_SIZE
(
2
);
char
*
xstrdup
(
const
char
*
str
);
enum
report_type
{
R_STATUS
=
0
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment