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
d98b9a46
Commit
d98b9a46
authored
Sep 18, 2006
by
Mikołaj Zalewski
Committed by
Alexandre Julliard
Sep 20, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comctl32: header: Simplify the insert/delete code by using ReAlloc.
parent
8ab78e18
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
64 deletions
+20
-64
header.c
dlls/comctl32/header.c
+20
-64
No files found.
dlls/comctl32/header.c
View file @
d98b9a46
...
...
@@ -1076,7 +1076,6 @@ HEADER_DeleteItem (HWND hwnd, WPARAM wParam)
infoPtr
->
uNumItem
=
0
;
}
else
{
HEADER_ITEM
*
oldItems
=
infoPtr
->
items
;
INT
i
;
INT
iOrder
;
TRACE
(
"Complex delete! [iItem=%d]
\n
"
,
iItem
);
...
...
@@ -1087,26 +1086,14 @@ HEADER_DeleteItem (HWND hwnd, WPARAM wParam)
iOrder
=
infoPtr
->
items
[
iItem
].
iOrder
;
infoPtr
->
uNumItem
--
;
infoPtr
->
items
=
Alloc
(
sizeof
(
HEADER_ITEM
)
*
infoPtr
->
uNumItem
);
/* pre delete copy */
if
(
iItem
>
0
)
{
memcpy
(
&
infoPtr
->
items
[
0
],
&
oldItems
[
0
],
iItem
*
sizeof
(
HEADER_ITEM
));
}
/* post delete copy */
if
(
iItem
<
infoPtr
->
uNumItem
)
{
memcpy
(
&
infoPtr
->
items
[
iItem
],
&
oldItems
[
iItem
+
1
],
(
infoPtr
->
uNumItem
-
iItem
)
*
sizeof
(
HEADER_ITEM
));
}
memmove
(
&
infoPtr
->
items
[
iItem
],
&
infoPtr
->
items
[
iItem
+
1
],
(
infoPtr
->
uNumItem
-
iItem
)
*
sizeof
(
HEADER_ITEM
));
memmove
(
&
infoPtr
->
order
[
iOrder
],
&
infoPtr
->
order
[
iOrder
+
1
],
(
infoPtr
->
uNumItem
-
iOrder
)
*
sizeof
(
INT
));
infoPtr
->
items
=
ReAlloc
(
infoPtr
->
items
,
sizeof
(
HEADER_ITEM
)
*
infoPtr
->
uNumItem
);
infoPtr
->
order
=
ReAlloc
(
infoPtr
->
order
,
sizeof
(
INT
)
*
infoPtr
->
uNumItem
);
/* Correct the orders */
if
(
iOrder
<
infoPtr
->
uNumItem
)
{
memmove
(
&
infoPtr
->
order
[
iOrder
],
&
infoPtr
->
order
[
iOrder
+
1
],
(
infoPtr
->
uNumItem
-
iOrder
)
*
sizeof
(
INT
));
}
for
(
i
=
0
;
i
<
infoPtr
->
uNumItem
;
i
++
)
{
if
(
infoPtr
->
order
[
i
]
>
iItem
)
...
...
@@ -1117,7 +1104,6 @@ HEADER_DeleteItem (HWND hwnd, WPARAM wParam)
for
(
i
=
0
;
i
<
infoPtr
->
uNumItem
;
i
++
)
TRACE
(
"%d: order=%d, iOrder=%d, ->iOrder=%d
\n
"
,
i
,
infoPtr
->
order
[
i
],
infoPtr
->
items
[
i
].
iOrder
,
infoPtr
->
items
[
infoPtr
->
order
[
i
]].
iOrder
);
Free
(
oldItems
);
}
HEADER_SetItemBounds
(
hwnd
);
...
...
@@ -1300,46 +1286,18 @@ HEADER_InsertItemT (HWND hwnd, INT nItem, LPHDITEMW phdi, BOOL bUnicode)
else
if
(
infoPtr
->
uNumItem
<
iOrder
)
iOrder
=
infoPtr
->
uNumItem
;
if
(
infoPtr
->
uNumItem
==
0
)
{
infoPtr
->
items
=
Alloc
(
sizeof
(
HEADER_ITEM
));
infoPtr
->
order
=
Alloc
(
sizeof
(
INT
));
infoPtr
->
uNumItem
++
;
}
else
{
HEADER_ITEM
*
oldItems
=
infoPtr
->
items
;
INT
*
oldOrder
=
infoPtr
->
order
;
infoPtr
->
uNumItem
++
;
infoPtr
->
items
=
Alloc
(
sizeof
(
HEADER_ITEM
)
*
infoPtr
->
uNumItem
);
if
(
nItem
==
0
)
{
memcpy
(
&
infoPtr
->
items
[
1
],
&
oldItems
[
0
],
(
infoPtr
->
uNumItem
-
1
)
*
sizeof
(
HEADER_ITEM
));
}
else
{
/* pre insert copy */
if
(
nItem
>
0
)
{
memcpy
(
&
infoPtr
->
items
[
0
],
&
oldItems
[
0
],
nItem
*
sizeof
(
HEADER_ITEM
));
}
/* post insert copy */
if
(
nItem
<
infoPtr
->
uNumItem
-
1
)
{
memcpy
(
&
infoPtr
->
items
[
nItem
+
1
],
&
oldItems
[
nItem
],
(
infoPtr
->
uNumItem
-
nItem
-
1
)
*
sizeof
(
HEADER_ITEM
));
}
}
infoPtr
->
order
=
Alloc
(
sizeof
(
INT
)
*
infoPtr
->
uNumItem
);
memcpy
(
infoPtr
->
order
,
oldOrder
,
iOrder
*
sizeof
(
INT
));
infoPtr
->
order
[
iOrder
]
=
nItem
;
memcpy
(
&
infoPtr
->
order
[
iOrder
+
1
],
&
oldOrder
[
iOrder
],
(
infoPtr
->
uNumItem
-
iOrder
-
1
)
*
sizeof
(
INT
));
Free
(
oldItems
);
Free
(
oldOrder
);
}
infoPtr
->
uNumItem
++
;
infoPtr
->
items
=
ReAlloc
(
infoPtr
->
items
,
sizeof
(
HEADER_ITEM
)
*
infoPtr
->
uNumItem
);
infoPtr
->
order
=
ReAlloc
(
infoPtr
->
order
,
sizeof
(
INT
)
*
infoPtr
->
uNumItem
);
/* make space for the new item */
memmove
(
&
infoPtr
->
items
[
nItem
+
1
],
&
infoPtr
->
items
[
nItem
],
(
infoPtr
->
uNumItem
-
nItem
-
1
)
*
sizeof
(
HEADER_ITEM
));
memmove
(
&
infoPtr
->
order
[
iOrder
+
1
],
&
infoPtr
->
order
[
iOrder
],
(
infoPtr
->
uNumItem
-
iOrder
-
1
)
*
sizeof
(
INT
));
/* update the order array */
infoPtr
->
order
[
iOrder
]
=
nItem
;
for
(
i
=
0
;
i
<
infoPtr
->
uNumItem
;
i
++
)
{
if
(
i
!=
iOrder
&&
infoPtr
->
order
[
i
]
>=
nItem
)
...
...
@@ -1352,6 +1310,7 @@ HEADER_InsertItemT (HWND hwnd, INT nItem, LPHDITEMW phdi, BOOL bUnicode)
/* cxy, fmt and lParam are copied even if not in the HDITEM mask */
copyMask
=
phdi
->
mask
|
HDI_WIDTH
|
HDI_FORMAT
|
HDI_LPARAM
;
HEADER_StoreHDItemInHeader
(
lpItem
,
copyMask
,
phdi
,
bUnicode
);
lpItem
->
iOrder
=
iOrder
;
/* set automatically some format bits */
if
(
phdi
->
mask
&
HDI_TEXT
)
...
...
@@ -1367,10 +1326,7 @@ HEADER_InsertItemT (HWND hwnd, INT nItem, LPHDITEMW phdi, BOOL bUnicode)
if
(
phdi
->
mask
&
HDI_IMAGE
)
lpItem
->
fmt
|=
HDF_IMAGE
;
lpItem
->
iOrder
=
iOrder
;
HEADER_SetItemBounds
(
hwnd
);
InvalidateRect
(
hwnd
,
NULL
,
FALSE
);
return
nItem
;
...
...
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