Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
a3c3283c
Commit
a3c3283c
authored
Oct 29, 2023
by
Alex Henrie
Committed by
Alexandre Julliard
Oct 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
find/tests: Use CRT allocation functions.
parent
caec1c24
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
12 deletions
+11
-12
find.c
programs/find/tests/find.c
+11
-12
No files found.
programs/find/tests/find.c
View file @
a3c3283c
...
@@ -19,7 +19,6 @@
...
@@ -19,7 +19,6 @@
#include <windows.h>
#include <windows.h>
#include <stdio.h>
#include <stdio.h>
#include "wine/heap.h"
#include "wine/test.h"
#include "wine/test.h"
static
void
read_all_from_handle
(
HANDLE
handle
,
BYTE
**
str
,
int
*
len
)
static
void
read_all_from_handle
(
HANDLE
handle
,
BYTE
**
str
,
int
*
len
)
...
@@ -27,14 +26,14 @@ static void read_all_from_handle(HANDLE handle, BYTE **str, int *len)
...
@@ -27,14 +26,14 @@ static void read_all_from_handle(HANDLE handle, BYTE **str, int *len)
char
buffer
[
4096
];
char
buffer
[
4096
];
DWORD
bytes_read
;
DWORD
bytes_read
;
DWORD
length
=
0
;
DWORD
length
=
0
;
BYTE
*
ret
=
heap_alloc_zero
(
1
);
BYTE
*
ret
=
calloc
(
1
,
1
);
for
(;;)
for
(;;)
{
{
BOOL
success
=
ReadFile
(
handle
,
buffer
,
sizeof
(
buffer
),
&
bytes_read
,
NULL
);
BOOL
success
=
ReadFile
(
handle
,
buffer
,
sizeof
(
buffer
),
&
bytes_read
,
NULL
);
if
(
!
success
||
!
bytes_read
)
if
(
!
success
||
!
bytes_read
)
break
;
break
;
ret
=
heap_
realloc
(
ret
,
length
+
bytes_read
);
ret
=
realloc
(
ret
,
length
+
bytes_read
);
memcpy
((
char
*
)
ret
+
length
,
buffer
,
bytes_read
);
memcpy
((
char
*
)
ret
+
length
,
buffer
,
bytes_read
);
length
+=
bytes_read
;
length
+=
bytes_read
;
}
}
...
@@ -64,8 +63,8 @@ static void check_find_output(const BYTE *child_output, int child_output_len, co
...
@@ -64,8 +63,8 @@ static void check_find_output(const BYTE *child_output, int child_output_len, co
}
}
/* Format strings for debug printing */
/* Format strings for debug printing */
child_output_copy
=
heap_alloc_zero
(
child_output_len
*
4
+
1
);
child_output_copy
=
calloc
(
1
,
child_output_len
*
4
+
1
);
out_expected_copy
=
heap_alloc_zero
(
out_expected_len
*
4
+
1
);
out_expected_copy
=
calloc
(
1
,
out_expected_len
*
4
+
1
);
for
(
i
=
0
,
pos
=
0
;
i
<
child_output_len
;
i
++
)
for
(
i
=
0
,
pos
=
0
;
i
<
child_output_len
;
i
++
)
{
{
...
@@ -97,8 +96,8 @@ static void check_find_output(const BYTE *child_output, int child_output_len, co
...
@@ -97,8 +96,8 @@ static void check_find_output(const BYTE *child_output, int child_output_len, co
"####################
\n
"
,
"####################
\n
"
,
out_expected_copy
,
child_output_copy
);
out_expected_copy
,
child_output_copy
);
heap_
free
(
child_output_copy
);
free
(
child_output_copy
);
heap_
free
(
out_expected_copy
);
free
(
out_expected_copy
);
}
}
static
void
mangle_text
(
const
BYTE
*
input
,
int
input_len
,
BYTE
*
output
,
int
output_max
,
int
*
output_len
)
{
static
void
mangle_text
(
const
BYTE
*
input
,
int
input_len
,
BYTE
*
output
,
int
output_max
,
int
*
output_len
)
{
...
@@ -176,7 +175,7 @@ static void run_find_stdin_(const WCHAR *commandline, const BYTE *input, int inp
...
@@ -176,7 +175,7 @@ static void run_find_stdin_(const WCHAR *commandline, const BYTE *input, int inp
ok_
(
file
,
line
)(
exitcode
==
exitcode_expected
,
"Expected exitcode %d, got %ld
\n
"
,
exitcode_expected
,
exitcode
);
ok_
(
file
,
line
)(
exitcode
==
exitcode_expected
,
"Expected exitcode %d, got %ld
\n
"
,
exitcode_expected
,
exitcode
);
heap_
free
(
child_output
);
free
(
child_output
);
}
}
static
void
run_find_file_
(
const
WCHAR
*
commandline
,
const
BYTE
*
input
,
int
input_len
,
const
BYTE
*
out_expected
,
int
out_expected_len
,
int
exitcode_expected
,
const
char
*
file
,
int
line
)
static
void
run_find_file_
(
const
WCHAR
*
commandline
,
const
BYTE
*
input
,
int
input_len
,
const
BYTE
*
out_expected
,
int
out_expected_len
,
int
exitcode_expected
,
const
char
*
file
,
int
line
)
...
@@ -200,12 +199,12 @@ static void run_find_file_(const WCHAR *commandline, const BYTE *input, int inpu
...
@@ -200,12 +199,12 @@ static void run_find_file_(const WCHAR *commandline, const BYTE *input, int inpu
CharUpperA
(
path_temp_file
);
CharUpperA
(
path_temp_file
);
wsprintfA
(
header
,
"
\r\n
---------- %s
\r\n
"
,
path_temp_file
);
wsprintfA
(
header
,
"
\r\n
---------- %s
\r\n
"
,
path_temp_file
);
header_len
=
lstrlenA
(
header
);
header_len
=
lstrlenA
(
header
);
out_expected_new
=
heap_
alloc
(
header_len
+
out_expected_len
);
out_expected_new
=
m
alloc
(
header_len
+
out_expected_len
);
memcpy
(
out_expected_new
,
header
,
header_len
);
memcpy
(
out_expected_new
,
header
,
header_len
);
memcpy
(
out_expected_new
+
header_len
,
out_expected
,
out_expected_len
);
memcpy
(
out_expected_new
+
header_len
,
out_expected
,
out_expected_len
);
run_find_stdin_
(
commandline_new
,
(
BYTE
*
)
""
,
0
,
out_expected_new
,
header_len
+
out_expected_len
,
exitcode_expected
,
file
,
line
);
run_find_stdin_
(
commandline_new
,
(
BYTE
*
)
""
,
0
,
out_expected_new
,
header_len
+
out_expected_len
,
exitcode_expected
,
file
,
line
);
heap_
free
(
out_expected_new
);
free
(
out_expected_new
);
DeleteFileA
(
path_temp_file
);
DeleteFileA
(
path_temp_file
);
}
}
...
@@ -223,14 +222,14 @@ static void run_find_str_(const char *commandline, const char *input, const char
...
@@ -223,14 +222,14 @@ static void run_find_str_(const char *commandline, const char *input, const char
/* Turn commandline into WCHAR string */
/* Turn commandline into WCHAR string */
len_commandlineW
=
MultiByteToWideChar
(
CP_UTF8
,
0
,
commandline
,
-
1
,
0
,
0
);
len_commandlineW
=
MultiByteToWideChar
(
CP_UTF8
,
0
,
commandline
,
-
1
,
0
,
0
);
commandlineW
=
heap_
alloc
(
len_commandlineW
*
sizeof
(
WCHAR
));
commandlineW
=
m
alloc
(
len_commandlineW
*
sizeof
(
WCHAR
));
MultiByteToWideChar
(
CP_UTF8
,
0
,
commandline
,
-
1
,
commandlineW
,
len_commandlineW
);
MultiByteToWideChar
(
CP_UTF8
,
0
,
commandline
,
-
1
,
commandlineW
,
len_commandlineW
);
if
(
is_file
)
if
(
is_file
)
run_find_file_
(
commandlineW
,
(
BYTE
*
)
input
,
lstrlenA
(
input
),
(
BYTE
*
)
out_expected
,
lstrlenA
(
out_expected
),
exitcode_expected
,
file
,
line
);
run_find_file_
(
commandlineW
,
(
BYTE
*
)
input
,
lstrlenA
(
input
),
(
BYTE
*
)
out_expected
,
lstrlenA
(
out_expected
),
exitcode_expected
,
file
,
line
);
else
else
run_find_stdin_
(
commandlineW
,
(
BYTE
*
)
input
,
lstrlenA
(
input
),
(
BYTE
*
)
out_expected
,
lstrlenA
(
out_expected
),
exitcode_expected
,
file
,
line
);
run_find_stdin_
(
commandlineW
,
(
BYTE
*
)
input
,
lstrlenA
(
input
),
(
BYTE
*
)
out_expected
,
lstrlenA
(
out_expected
),
exitcode_expected
,
file
,
line
);
heap_
free
(
commandlineW
);
free
(
commandlineW
);
}
}
#define run_find_stdin_unicode(input, out_expected, exitcode_expected) \
#define run_find_stdin_unicode(input, out_expected, exitcode_expected) \
...
...
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