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
4dae7748
Commit
4dae7748
authored
May 23, 2010
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Reimplement bsearch to avoid redundant and possibly out of bounds comparisons.
parent
bd3110d8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
16 deletions
+9
-16
misc.c
dlls/ntdll/misc.c
+9
-16
No files found.
dlls/ntdll/misc.c
View file @
4dae7748
...
...
@@ -302,27 +302,20 @@ void * __cdecl
NTDLL_bsearch
(
const
void
*
key
,
const
void
*
base
,
size_t
nmemb
,
size_t
size
,
int
(
__cdecl
*
compar
)(
const
void
*
,
const
void
*
)
)
{
int
begin
,
end
,
cursor
;
begin
=
0
;
end
=
nmemb
-
1
;
while
(
1
)
{
int
ret
;
cursor
=
(
end
-
begin
)
/
2
+
begin
;
ret
=
compar
(
key
,(
char
*
)
base
+
(
cursor
*
size
));
ssize_t
min
=
0
;
ssize_t
max
=
nmemb
-
1
;
while
(
min
<=
max
)
{
ssize_t
cursor
=
(
min
+
max
)
/
2
;
int
ret
=
compar
(
key
,(
const
char
*
)
base
+
(
cursor
*
size
));
if
(
!
ret
)
return
(
char
*
)
base
+
(
cursor
*
size
);
if
(
ret
<
0
)
end
=
cursor
;
max
=
cursor
-
1
;
else
begin
=
cursor
;
if
((
end
-
begin
)
<=
1
)
break
;
min
=
cursor
+
1
;
}
if
(
!
compar
(
key
,(
char
*
)
base
+
(
begin
*
size
)))
return
(
char
*
)
base
+
(
begin
*
size
);
if
(
!
compar
(
key
,(
char
*
)
base
+
(
end
*
size
)))
return
(
char
*
)
base
+
(
end
*
size
);
return
NULL
;
}
...
...
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