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
f428813c
Commit
f428813c
authored
Jul 24, 2009
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winemenubuilder: Reduce memory usage for string copies.
parent
464c956a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
winemenubuilder.c
programs/winemenubuilder/winemenubuilder.c
+18
-7
No files found.
programs/winemenubuilder/winemenubuilder.c
View file @
f428813c
...
...
@@ -692,11 +692,20 @@ static unsigned short crc16(const char* string)
return
crc
;
}
static
char
*
strdupA
(
const
char
*
str
)
{
char
*
ret
;
if
(
!
str
)
return
NULL
;
if
((
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
str
)
+
1
)))
strcpy
(
ret
,
str
);
return
ret
;
}
static
char
*
heap_printf
(
const
char
*
format
,
...)
{
va_list
args
;
int
size
=
4096
;
char
*
buffer
;
char
*
buffer
,
*
ret
;
int
n
;
va_start
(
args
,
format
);
...
...
@@ -715,7 +724,9 @@ static char* heap_printf(const char *format, ...)
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
va_end
(
args
);
return
buffer
;
ret
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
buffer
,
strlen
(
buffer
)
+
1
);
if
(
!
ret
)
ret
=
buffer
;
return
ret
;
}
static
BOOL
create_directories
(
char
*
directory
)
...
...
@@ -1429,8 +1440,8 @@ static BOOL add_mimes(const char *xdg_data_dir, struct list *mime_types)
if
(
mime_type_entry
)
{
*
pos
=
0
;
mime_type_entry
->
mimeType
=
heap_printf
(
"%s"
,
line
);
mime_type_entry
->
glob
=
heap_printf
(
"%s"
,
pos
+
1
);
mime_type_entry
->
mimeType
=
strdupA
(
line
);
mime_type_entry
->
glob
=
strdupA
(
pos
+
1
);
if
(
mime_type_entry
->
mimeType
&&
mime_type_entry
->
glob
)
list_add_tail
(
mime_types
,
&
mime_type_entry
->
entry
);
else
...
...
@@ -1480,7 +1491,7 @@ static BOOL build_native_mime_types(const char *xdg_data_home, struct list **mim
if
(
xdg_data_dirs
==
NULL
)
xdg_data_dirs
=
heap_printf
(
"/usr/local/share/:/usr/share/"
);
else
xdg_data_dirs
=
heap_printf
(
"%s"
,
xdg_data_dirs
);
xdg_data_dirs
=
strdupA
(
xdg_data_dirs
);
if
(
xdg_data_dirs
)
{
...
...
@@ -1543,7 +1554,7 @@ static BOOL match_glob(struct list *native_mime_types, const char *extension,
if
(
*
match
!=
NULL
)
{
*
match
=
heap_printf
(
"%s"
,
*
match
);
*
match
=
strdupA
(
*
match
);
if
(
*
match
==
NULL
)
return
FALSE
;
}
...
...
@@ -2664,7 +2675,7 @@ static BOOL init_xdg(void)
{
create_directories
(
xdg_config_dir
);
if
(
getenv
(
"XDG_DATA_HOME"
))
xdg_data_dir
=
heap_printf
(
"%s"
,
getenv
(
"XDG_DATA_HOME"
));
xdg_data_dir
=
strdupA
(
getenv
(
"XDG_DATA_HOME"
));
else
xdg_data_dir
=
heap_printf
(
"%s/.local/share"
,
getenv
(
"HOME"
));
if
(
xdg_data_dir
)
...
...
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