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
8d2e59ed
Commit
8d2e59ed
authored
Feb 13, 2019
by
Nikolay Sivov
Committed by
Alexandre Julliard
Feb 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite: Use more appropriate allocation helpers.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
35b01d62
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
41 deletions
+42
-41
analyzer.c
dlls/dwrite/analyzer.c
+10
-10
bidi.c
dlls/dwrite/bidi.c
+1
-1
font.c
dlls/dwrite/font.c
+11
-11
layout.c
dlls/dwrite/layout.c
+16
-16
main.c
dlls/dwrite/main.c
+4
-3
No files found.
dlls/dwrite/analyzer.c
View file @
8d2e59ed
...
...
@@ -448,7 +448,7 @@ static HRESULT analyze_linebreaks(const WCHAR *text, UINT32 count, DWRITE_LINE_B
short
*
break_class
;
int
i
,
j
;
break_class
=
heap_
alloc
(
count
*
sizeof
(
short
));
break_class
=
heap_
calloc
(
count
,
sizeof
(
*
break_class
));
if
(
!
break_class
)
return
E_OUTOFMEMORY
;
...
...
@@ -937,8 +937,8 @@ static HRESULT WINAPI dwritetextanalyzer_AnalyzeBidi(IDWriteTextAnalyzer2 *iface
if
(
FAILED
(
hr
))
return
hr
;
levels
=
heap_
alloc
(
length
*
sizeof
(
*
levels
));
explicit
=
heap_
alloc
(
length
*
sizeof
(
*
explicit
));
levels
=
heap_
calloc
(
length
,
sizeof
(
*
levels
));
explicit
=
heap_
calloc
(
length
,
sizeof
(
*
explicit
));
if
(
!
levels
||
!
explicit
)
{
hr
=
E_OUTOFMEMORY
;
...
...
@@ -1013,7 +1013,7 @@ static HRESULT WINAPI dwritetextanalyzer_AnalyzeLineBreakpoints(IDWriteTextAnaly
if
(
len
<
length
)
{
UINT32
read
;
buff
=
heap_
alloc
(
length
*
sizeof
(
WCHAR
));
buff
=
heap_
calloc
(
length
,
sizeof
(
*
buff
));
if
(
!
buff
)
return
E_OUTOFMEMORY
;
memcpy
(
buff
,
text
,
len
*
sizeof
(
WCHAR
));
...
...
@@ -1032,7 +1032,7 @@ static HRESULT WINAPI dwritetextanalyzer_AnalyzeLineBreakpoints(IDWriteTextAnaly
text
=
buff
;
}
breakpoints
=
heap_
alloc
(
length
*
sizeof
(
*
breakpoints
));
breakpoints
=
heap_
calloc
(
length
,
sizeof
(
*
breakpoints
));
if
(
!
breakpoints
)
{
hr
=
E_OUTOFMEMORY
;
goto
done
;
...
...
@@ -1176,7 +1176,7 @@ static HRESULT WINAPI dwritetextanalyzer_GetGlyphs(IDWriteTextAnalyzer2 *iface,
if
(
max_glyph_count
<
length
)
return
E_NOT_SUFFICIENT_BUFFER
;
string
=
heap_
alloc
(
sizeof
(
WCHAR
)
*
length
);
string
=
heap_
calloc
(
length
,
sizeof
(
*
string
)
);
if
(
!
string
)
return
E_OUTOFMEMORY
;
...
...
@@ -1432,7 +1432,7 @@ static HRESULT apply_cluster_spacing(float leading_spacing, float trailing_spaci
break
;
}
deltas
=
heap_
alloc
((
end
-
start
+
1
)
*
sizeof
(
*
deltas
));
deltas
=
heap_
calloc
(
end
-
start
+
1
,
sizeof
(
*
deltas
));
if
(
!
deltas
)
return
E_OUTOFMEMORY
;
...
...
@@ -1677,7 +1677,7 @@ static HRESULT WINAPI dwritetextanalyzer1_GetTextComplexity(IDWriteTextAnalyzer2
/* fetch indices */
if
(
*
is_simple
&&
indices
)
{
UINT32
*
codepoints
=
heap_
alloc
(
*
len_read
*
sizeof
(
UINT32
));
UINT32
*
codepoints
=
heap_
calloc
(
*
len_read
,
sizeof
(
*
codepoints
));
if
(
!
codepoints
)
return
E_OUTOFMEMORY
;
...
...
@@ -2305,7 +2305,7 @@ static HRESULT WINAPI fontfallbackbuilder_AddMapping(IDWriteFontFallbackBuilder
struct
fallback_mapping
*
mappings
;
if
(
fallbackbuilder
->
mappings_capacity
==
0
)
{
if
((
mappings
=
heap_
alloc
(
sizeof
(
*
fallbackbuilder
->
mappings
)
*
16
)))
if
((
mappings
=
heap_
calloc
(
16
,
sizeof
(
*
mappings
)
)))
fallbackbuilder
->
mappings_capacity
=
16
;
}
else
{
...
...
@@ -2321,7 +2321,7 @@ static HRESULT WINAPI fontfallbackbuilder_AddMapping(IDWriteFontFallbackBuilder
mapping
=
&
fallbackbuilder
->
mappings
[
fallbackbuilder
->
mappings_count
++
];
mapping
->
ranges
=
heap_
alloc
(
sizeof
(
*
mapping
->
ranges
)
*
ranges_count
);
mapping
->
ranges
=
heap_
calloc
(
ranges_count
,
sizeof
(
*
mapping
->
ranges
)
);
memcpy
(
mapping
->
ranges
,
ranges
,
sizeof
(
*
mapping
->
ranges
)
*
ranges_count
);
mapping
->
ranges_count
=
ranges_count
;
mapping
->
families
=
heap_alloc_zero
(
sizeof
(
*
mapping
->
families
)
*
families_count
);
...
...
dlls/dwrite/bidi.c
View file @
8d2e59ed
...
...
@@ -964,7 +964,7 @@ static HRESULT bidi_compute_isolating_runs_set(UINT8 baselevel, UINT8 *classes,
HRESULT
hr
=
S_OK
;
Run
*
runs
;
runs
=
heap_
alloc
(
count
*
sizeof
(
Run
));
runs
=
heap_
calloc
(
count
,
sizeof
(
*
runs
));
if
(
!
runs
)
return
E_OUTOFMEMORY
;
...
...
dlls/dwrite/font.c
View file @
8d2e59ed
...
...
@@ -2227,7 +2227,7 @@ static HRESULT WINAPI dwritefontfamily_GetMatchingFonts(IDWriteFontFamily1 *ifac
return
E_OUTOFMEMORY
;
/* Allocate as many as family has, not all of them will be necessary used. */
fonts
->
fonts
=
heap_
alloc
(
sizeof
(
*
fonts
->
fonts
)
*
This
->
data
->
font_count
);
fonts
->
fonts
=
heap_
calloc
(
This
->
data
->
font_count
,
sizeof
(
*
fonts
->
fonts
)
);
if
(
!
fonts
->
fonts
)
{
heap_free
(
fonts
);
return
E_OUTOFMEMORY
;
...
...
@@ -2718,7 +2718,7 @@ static HRESULT init_font_collection(struct dwrite_fontcollection *collection, BO
collection
->
ref
=
1
;
collection
->
family_count
=
0
;
collection
->
family_alloc
=
is_system
?
30
:
5
;
collection
->
family_data
=
heap_
alloc
(
sizeof
(
*
collection
->
family_data
)
*
collection
->
family_alloc
);
collection
->
family_data
=
heap_
calloc
(
collection
->
family_alloc
,
sizeof
(
*
collection
->
family_data
)
);
if
(
!
collection
->
family_data
)
return
E_OUTOFMEMORY
;
...
...
@@ -3567,7 +3567,7 @@ static HRESULT init_fontfamily_data(IDWriteLocalizedStrings *familyname, struct
data
->
has_oblique_face
=
0
;
data
->
has_italic_face
=
0
;
data
->
fonts
=
heap_
alloc
(
sizeof
(
*
data
->
fonts
)
*
data
->
font_alloc
);
data
->
fonts
=
heap_
calloc
(
data
->
font_alloc
,
sizeof
(
*
data
->
fonts
)
);
if
(
!
data
->
fonts
)
{
heap_free
(
data
);
return
E_OUTOFMEMORY
;
...
...
@@ -5475,8 +5475,8 @@ HRESULT create_glyphrunanalysis(const struct glyphrunanalysis_desc *desc, IDWrit
SetRectEmpty
(
&
analysis
->
bounds
);
analysis
->
run
=
*
desc
->
run
;
IDWriteFontFace_AddRef
(
analysis
->
run
.
fontFace
);
analysis
->
glyphs
=
heap_
alloc
(
desc
->
run
->
glyphCount
*
sizeof
(
*
analysis
->
glyphs
));
analysis
->
origins
=
heap_
alloc
(
desc
->
run
->
glyphCount
*
sizeof
(
*
analysis
->
origins
));
analysis
->
glyphs
=
heap_
calloc
(
desc
->
run
->
glyphCount
,
sizeof
(
*
analysis
->
glyphs
));
analysis
->
origins
=
heap_
calloc
(
desc
->
run
->
glyphCount
,
sizeof
(
*
analysis
->
origins
));
if
(
!
analysis
->
glyphs
||
!
analysis
->
origins
)
{
heap_free
(
analysis
->
glyphs
);
...
...
@@ -5814,12 +5814,12 @@ HRESULT create_colorglyphenum(float originX, float originY, const DWRITE_GLYPH_R
return
DWRITE_E_NOCOLOR
;
}
colorglyphenum
->
advances
=
heap_
alloc
(
run
->
glyphCount
*
sizeof
(
FLOAT
));
colorglyphenum
->
color_advances
=
heap_
alloc
(
run
->
glyphCount
*
sizeof
(
FLOAT
));
colorglyphenum
->
glyphindices
=
heap_
alloc
(
run
->
glyphCount
*
sizeof
(
UINT16
));
colorglyphenum
->
advances
=
heap_
calloc
(
run
->
glyphCount
,
sizeof
(
*
colorglyphenum
->
advances
));
colorglyphenum
->
color_advances
=
heap_
calloc
(
run
->
glyphCount
,
sizeof
(
*
colorglyphenum
->
color_advances
));
colorglyphenum
->
glyphindices
=
heap_
calloc
(
run
->
glyphCount
,
sizeof
(
*
colorglyphenum
->
glyphindices
));
if
(
run
->
glyphOffsets
)
{
colorglyphenum
->
offsets
=
heap_
alloc
(
run
->
glyphCount
*
sizeof
(
*
colorglyphenum
->
offsets
));
colorglyphenum
->
color_offsets
=
heap_
alloc
(
run
->
glyphCount
*
sizeof
(
*
colorglyphenum
->
color_offsets
));
colorglyphenum
->
offsets
=
heap_
calloc
(
run
->
glyphCount
,
sizeof
(
*
colorglyphenum
->
offsets
));
colorglyphenum
->
color_offsets
=
heap_
calloc
(
run
->
glyphCount
,
sizeof
(
*
colorglyphenum
->
color_offsets
));
memcpy
(
colorglyphenum
->
offsets
,
run
->
glyphOffsets
,
run
->
glyphCount
*
sizeof
(
*
run
->
glyphOffsets
));
}
...
...
@@ -6311,7 +6311,7 @@ static HRESULT WINAPI inmemoryfontfileloader_CreateInMemoryFontFileReference(IDW
}
else
{
loader
->
capacity
=
16
;
loader
->
streams
=
heap_
alloc
(
loader
->
capacity
*
sizeof
(
*
loader
->
streams
));
loader
->
streams
=
heap_
calloc
(
loader
->
capacity
,
sizeof
(
*
loader
->
streams
));
}
}
...
...
dlls/dwrite/layout.c
View file @
8d2e59ed
...
...
@@ -594,7 +594,7 @@ static HRESULT layout_update_breakpoints_range(struct dwrite_textlayout *layout,
after
=
before
=
DWRITE_BREAK_CONDITION_NEUTRAL
;
if
(
!
layout
->
actual_breakpoints
)
{
layout
->
actual_breakpoints
=
heap_
alloc
(
sizeof
(
DWRITE_LINE_BREAKPOINT
)
*
layout
->
len
);
layout
->
actual_breakpoints
=
heap_
calloc
(
layout
->
len
,
sizeof
(
*
layout
->
actual_breakpoints
)
);
if
(
!
layout
->
actual_breakpoints
)
return
E_OUTOFMEMORY
;
memcpy
(
layout
->
actual_breakpoints
,
layout
->
nominal_breakpoints
,
sizeof
(
DWRITE_LINE_BREAKPOINT
)
*
layout
->
len
);
...
...
@@ -933,15 +933,15 @@ static HRESULT layout_shape_run(struct dwrite_textlayout *layout, struct regular
range
=
get_layout_range_by_pos
(
layout
,
run
->
descr
.
textPosition
);
run
->
descr
.
localeName
=
range
->
locale
;
run
->
clustermap
=
heap_
alloc
(
run
->
descr
.
stringLength
*
sizeof
(
*
run
->
clustermap
));
run
->
clustermap
=
heap_
calloc
(
run
->
descr
.
stringLength
,
sizeof
(
*
run
->
clustermap
));
max_count
=
3
*
run
->
descr
.
stringLength
/
2
+
16
;
run
->
glyphs
=
heap_
alloc
(
max_count
*
sizeof
(
*
run
->
glyphs
));
run
->
glyphs
=
heap_
calloc
(
max_count
,
sizeof
(
*
run
->
glyphs
));
if
(
!
run
->
clustermap
||
!
run
->
glyphs
)
return
E_OUTOFMEMORY
;
text_props
=
heap_
alloc
(
run
->
descr
.
stringLength
*
sizeof
(
*
text_props
));
glyph_props
=
heap_
alloc
(
max_count
*
sizeof
(
*
glyph_props
));
text_props
=
heap_
calloc
(
run
->
descr
.
stringLength
,
sizeof
(
*
text_props
));
glyph_props
=
heap_
calloc
(
max_count
,
sizeof
(
*
glyph_props
));
if
(
!
text_props
||
!
glyph_props
)
{
heap_free
(
text_props
);
heap_free
(
glyph_props
);
...
...
@@ -960,8 +960,8 @@ static HRESULT layout_shape_run(struct dwrite_textlayout *layout, struct regular
max_count
=
run
->
glyphcount
;
run
->
glyphs
=
heap_
alloc
(
max_count
*
sizeof
(
*
run
->
glyphs
));
glyph_props
=
heap_
alloc
(
max_count
*
sizeof
(
*
glyph_props
));
run
->
glyphs
=
heap_
calloc
(
max_count
,
sizeof
(
*
run
->
glyphs
));
glyph_props
=
heap_
calloc
(
max_count
,
sizeof
(
*
glyph_props
));
if
(
!
run
->
glyphs
||
!
glyph_props
)
{
hr
=
E_OUTOFMEMORY
;
break
;
...
...
@@ -983,8 +983,8 @@ static HRESULT layout_shape_run(struct dwrite_textlayout *layout, struct regular
run
->
run
.
glyphIndices
=
run
->
glyphs
;
run
->
descr
.
clusterMap
=
run
->
clustermap
;
run
->
advances
=
heap_
alloc
(
run
->
glyphcount
*
sizeof
(
*
run
->
advances
));
run
->
offsets
=
heap_
alloc
(
run
->
glyphcount
*
sizeof
(
*
run
->
offsets
));
run
->
advances
=
heap_
calloc
(
run
->
glyphcount
,
sizeof
(
*
run
->
advances
));
run
->
offsets
=
heap_
calloc
(
run
->
glyphcount
,
sizeof
(
*
run
->
offsets
));
if
(
!
run
->
advances
||
!
run
->
offsets
)
return
E_OUTOFMEMORY
;
...
...
@@ -1034,8 +1034,8 @@ static HRESULT layout_compute_runs(struct dwrite_textlayout *layout)
/* Cluster data arrays are allocated once, assuming one text position per cluster. */
if
(
!
layout
->
clustermetrics
&&
layout
->
len
)
{
layout
->
clustermetrics
=
heap_
alloc
(
layout
->
len
*
sizeof
(
*
layout
->
clustermetrics
));
layout
->
clusters
=
heap_
alloc
(
layout
->
len
*
sizeof
(
*
layout
->
clusters
));
layout
->
clustermetrics
=
heap_
calloc
(
layout
->
len
,
sizeof
(
*
layout
->
clustermetrics
));
layout
->
clusters
=
heap_
calloc
(
layout
->
len
,
sizeof
(
*
layout
->
clusters
));
if
(
!
layout
->
clustermetrics
||
!
layout
->
clusters
)
{
heap_free
(
layout
->
clustermetrics
);
heap_free
(
layout
->
clusters
);
...
...
@@ -1122,7 +1122,7 @@ static HRESULT layout_compute(struct dwrite_textlayout *layout)
if
(
!
layout
->
nominal_breakpoints
)
{
IDWriteTextAnalyzer
*
analyzer
;
layout
->
nominal_breakpoints
=
heap_
alloc
(
layout
->
len
*
sizeof
(
*
layout
->
nominal_breakpoints
));
layout
->
nominal_breakpoints
=
heap_
calloc
(
layout
->
len
,
sizeof
(
*
layout
->
nominal_breakpoints
));
if
(
!
layout
->
nominal_breakpoints
)
return
E_OUTOFMEMORY
;
...
...
@@ -1291,7 +1291,7 @@ static HRESULT layout_add_effective_run(struct dwrite_textlayout *layout, const
length
=
layout
->
clusters
[
last_cluster
].
position
-
layout
->
clusters
[
first_cluster
].
position
+
layout
->
clustermetrics
[
last_cluster
].
length
;
run
->
clustermap
=
heap_
alloc
(
sizeof
(
UINT16
)
*
length
);
run
->
clustermap
=
heap_
calloc
(
length
,
sizeof
(
*
run
->
clustermap
)
);
if
(
!
run
->
clustermap
)
{
heap_free
(
run
);
return
E_OUTOFMEMORY
;
...
...
@@ -1386,8 +1386,8 @@ static HRESULT layout_set_line_metrics(struct dwrite_textlayout *layout, DWRITE_
if
(
!
layout
->
line_alloc
)
{
layout
->
line_alloc
=
5
;
layout
->
linemetrics
=
heap_
alloc
(
layout
->
line_alloc
*
sizeof
(
*
layout
->
linemetrics
));
layout
->
lines
=
heap_
alloc
(
layout
->
line_alloc
*
sizeof
(
*
layout
->
lines
));
layout
->
linemetrics
=
heap_
calloc
(
layout
->
line_alloc
,
sizeof
(
*
layout
->
linemetrics
));
layout
->
lines
=
heap_
calloc
(
layout
->
line_alloc
,
sizeof
(
*
layout
->
lines
));
if
(
!
layout
->
linemetrics
||
!
layout
->
lines
)
{
heap_free
(
layout
->
linemetrics
);
heap_free
(
layout
->
lines
);
...
...
@@ -5787,7 +5787,7 @@ HRESULT create_typography(IDWriteTypography **ret)
typography
->
allocated
=
2
;
typography
->
count
=
0
;
typography
->
features
=
heap_
alloc
(
typography
->
allocated
*
sizeof
(
DWRITE_FONT_FEATURE
));
typography
->
features
=
heap_
calloc
(
typography
->
allocated
,
sizeof
(
*
typography
->
features
));
if
(
!
typography
->
features
)
{
heap_free
(
typography
);
return
E_OUTOFMEMORY
;
...
...
dlls/dwrite/main.c
View file @
8d2e59ed
...
...
@@ -483,13 +483,14 @@ HRESULT clone_localizedstring(IDWriteLocalizedStrings *iface, IDWriteLocalizedSt
return
S_FALSE
;
strings
=
impl_from_IDWriteLocalizedStrings
(
iface
);
strings_clone
=
heap_alloc
(
sizeof
(
struct
localizedstrings
));
if
(
!
strings_clone
)
return
E_OUTOFMEMORY
;
strings_clone
=
heap_alloc
(
sizeof
(
*
strings_clone
));
if
(
!
strings_clone
)
return
E_OUTOFMEMORY
;
strings_clone
->
IDWriteLocalizedStrings_iface
.
lpVtbl
=
&
localizedstringsvtbl
;
strings_clone
->
ref
=
1
;
strings_clone
->
count
=
strings
->
count
;
strings_clone
->
data
=
heap_
alloc
(
sizeof
(
struct
localizedpair
)
*
strings_clone
->
count
);
strings_clone
->
data
=
heap_
calloc
(
strings_clone
->
count
,
sizeof
(
*
strings_clone
->
data
)
);
if
(
!
strings_clone
->
data
)
{
heap_free
(
strings_clone
);
return
E_OUTOFMEMORY
;
...
...
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