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
9fb00ff5
Commit
9fb00ff5
authored
Aug 01, 2005
by
Felix Nawothnig
Committed by
Alexandre Julliard
Aug 01, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix DPA_Search for sorted arrays.
parent
d15e2f14
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
24 deletions
+7
-24
dpa.c
dlls/comctl32/dpa.c
+6
-23
dpa.c
dlls/comctl32/tests/dpa.c
+1
-1
No files found.
dlls/comctl32/dpa.c
View file @
9fb00ff5
...
...
@@ -787,11 +787,6 @@ BOOL WINAPI DPA_Sort (const HDPA hdpa, PFNDPACOMPARE pfnCompare, LPARAM lParam)
* RETURNS
* Success: index of the pointer in the array.
* Failure: -1
*
* NOTES
* Binary search taken from R.Sedgewick "Algorithms in C"!
* Function is NOT tested!
* If something goes wrong, blame HIM not ME! (Eric Kohl)
*/
INT
WINAPI
DPA_Search
(
const
HDPA
hdpa
,
LPVOID
pFind
,
INT
nStart
,
PFNDPACOMPARE
pfnCompare
,
LPARAM
lParam
,
UINT
uOptions
)
...
...
@@ -807,47 +802,35 @@ INT WINAPI DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart,
INT
l
,
r
,
x
,
n
;
LPVOID
*
lpPtr
;
TRACE
(
"binary search
\n
"
);
l
=
(
nStart
==
-
1
)
?
0
:
nStart
;
r
=
hdpa
->
nItemCount
-
1
;
lpPtr
=
hdpa
->
ptrs
;
while
(
r
>=
l
)
{
x
=
(
l
+
r
)
/
2
;
n
=
(
pfnCompare
)(
pFind
,
lpPtr
[
x
],
lParam
);
if
(
n
<
0
)
if
(
n
==
0
)
return
x
;
else
if
(
n
<
0
)
r
=
x
-
1
;
else
else
/* (n > 0) */
l
=
x
+
1
;
if
(
n
==
0
)
{
TRACE
(
"-- ret=%d
\n
"
,
n
);
return
n
;
}
}
if
(
uOptions
&
(
DPAS_INSERTBEFORE
|
DPAS_INSERTAFTER
))
{
TRACE
(
"-- ret=%d
\n
"
,
l
);
return
l
;
}
return
l
;
}
else
{
/* array is not sorted --> use linear search */
LPVOID
*
lpPtr
;
INT
nIndex
;
TRACE
(
"linear search
\n
"
);
nIndex
=
(
nStart
==
-
1
)
?
0
:
nStart
;
lpPtr
=
hdpa
->
ptrs
;
for
(;
nIndex
<
hdpa
->
nItemCount
;
nIndex
++
)
{
if
((
pfnCompare
)(
pFind
,
lpPtr
[
nIndex
],
lParam
)
==
0
)
{
TRACE
(
"-- ret=%d
\n
"
,
nIndex
);
if
((
pfnCompare
)(
pFind
,
lpPtr
[
nIndex
],
lParam
)
==
0
)
return
nIndex
;
}
}
}
TRACE
(
"-- not found: ret=-1
\n
"
);
return
-
1
;
}
...
...
dlls/comctl32/tests/dpa.c
View file @
9fb00ff5
...
...
@@ -274,7 +274,7 @@ static void test_dpa(void)
j
=
pDPA_GetPtrIndex
(
dpa
,
(
PVOID
)
i
);
ok
(
j
+
1
==
i
,
"j=%d i=%d
\n
"
,
j
,
i
);
j
=
pDPA_Search
(
dpa
,
(
PVOID
)
i
,
0
,
CB_CmpLT
,
0xdeadbeef
,
DPAS_SORTED
);
if
(
i
>
1
)
todo_wine
ok
(
j
+
1
==
i
,
"j=%d i=%d
\n
"
,
j
,
i
);
ok
(
j
+
1
==
i
,
"j=%d i=%d
\n
"
,
j
,
i
);
/* Linear searches respect iStart ... */
j
=
pDPA_Search
(
dpa
,
(
PVOID
)
i
,
i
+
1
,
CB_CmpLT
,
0xdeadbeef
,
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