Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lorenzo Ferrillo
wine
Commits
26b1bfa5
Commit
26b1bfa5
authored
13 years ago
by
Alexandre Julliard
Browse files
Options
Downloads
Patches
Plain Diff
gdi32: Use reallocs when growing a path instead of doing it by hand.
parent
ed95814e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dlls/gdi32/path.c
+11
-41
11 additions, 41 deletions
dlls/gdi32/path.c
with
11 additions
and
41 deletions
dlls/gdi32/path.c
+
11
−
41
View file @
26b1bfa5
...
...
@@ -74,8 +74,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdi);
*/
#define NUM_ENTRIES_INITIAL 16
/* Initial size of points / flags arrays */
#define GROW_FACTOR_NUMER 2
/* Numerator of grow factor for the array */
#define GROW_FACTOR_DENOM 1
/* Denominator of grow factor */
/* A floating point version of the POINT structure */
typedef
struct
tagFLOAT_POINT
...
...
@@ -144,59 +142,31 @@ static void PATH_EmptyPath(GdiPath *pPath)
* been allocated; allocates larger arrays and copies the existing entries
* to those arrays, if necessary. Returns TRUE if successful, else FALSE.
*/
static
BOOL
PATH_ReserveEntries
(
GdiPath
*
pPath
,
INT
numEntries
)
static
BOOL
PATH_ReserveEntries
(
GdiPath
*
pPath
,
INT
count
)
{
INT
numEntriesToAllocate
;
POINT
*
pPointsNew
;
BYTE
*
pFlagsNew
;
assert
(
numEntries
>=
0
);
assert
(
count
>=
0
);
/* Do we have to allocate more memory? */
if
(
numEntries
>
pPath
->
numEntriesAllocated
)
if
(
count
>
pPath
->
numEntriesAllocated
)
{
/* Find number of entries to allocate. We let the size of the array
* grow exponentially, since that will guarantee linear time
* complexity. */
if
(
pPath
->
numEntriesAllocated
)
{
numEntriesToAllocate
=
pPath
->
numEntriesAllocated
;
while
(
numEntriesToAllocate
<
numEntries
)
numEntriesToAllocate
=
numEntriesToAllocate
*
GROW_FACTOR_NUMER
/
GROW_FACTOR_DENOM
;
}
else
numEntriesToAllocate
=
numEntries
;
count
=
max
(
pPath
->
numEntriesAllocated
*
2
,
count
);
/* Allocate new arrays */
pPointsNew
=
HeapAlloc
(
GetProcessHeap
(),
0
,
numEntriesToAllocate
*
sizeof
(
POINT
)
);
if
(
!
pPointsNew
)
return
FALSE
;
pFlagsNew
=
HeapAlloc
(
GetProcessHeap
(),
0
,
numEntriesToAllocate
*
sizeof
(
BYTE
)
);
if
(
!
pFlagsNew
)
{
HeapFree
(
GetProcessHeap
(),
0
,
pPointsNew
);
return
FALSE
;
}
/* Copy old arrays to new arrays and discard old arrays */
if
(
pPath
->
pPoints
)
{
assert
(
pPath
->
pFlags
);
pPointsNew
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
pPath
->
pPoints
,
count
*
sizeof
(
POINT
)
);
if
(
!
pPointsNew
)
return
FALSE
;
pPath
->
pPoints
=
pPointsNew
;
memcpy
(
pPointsNew
,
pPath
->
pPoints
,
sizeof
(
POINT
)
*
pPath
->
numEntriesUsed
);
memcpy
(
pFlagsNew
,
pPath
->
pFlags
,
sizeof
(
BYTE
)
*
pPath
->
numEntriesUsed
);
pFlagsNew
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
pPath
->
pFlags
,
count
*
sizeof
(
BYTE
)
);
if
(
!
pFlagsNew
)
return
FALSE
;
pPath
->
pFlags
=
pFlagsNew
;
HeapFree
(
GetProcessHeap
(),
0
,
pPath
->
pPoints
);
HeapFree
(
GetProcessHeap
(),
0
,
pPath
->
pFlags
);
}
pPath
->
pPoints
=
pPointsNew
;
pPath
->
pFlags
=
pFlagsNew
;
pPath
->
numEntriesAllocated
=
numEntriesToAllocate
;
pPath
->
numEntriesAllocated
=
count
;
}
return
TRUE
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment