Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
dc689548
Commit
dc689548
authored
Feb 10, 2011
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ConfigKeyToString: simplify and fix potential leak
parent
09110552
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
29 deletions
+15
-29
src/config/keys.c
src/config/keys.c
+15
-29
No files found.
src/config/keys.c
View file @
dc689548
...
@@ -193,38 +193,24 @@ uint_fast32_t ConfigStringToKey (const char *name)
...
@@ -193,38 +193,24 @@ uint_fast32_t ConfigStringToKey (const char *name)
return
(
vlc_towc
(
name
,
&
cp
)
>
0
)
?
(
mods
|
cp
)
:
0
;
return
(
vlc_towc
(
name
,
&
cp
)
>
0
)
?
(
mods
|
cp
)
:
0
;
}
}
char
*
ConfigKeyToString
(
uint_fast32_t
i_key
)
char
*
ConfigKeyToString
(
uint_fast32_t
code
)
{
{
// Worst case appears to be 45 characters:
char
*
str
,
buf
[
5
];
// "Command-Meta-Ctrl-Shift-Alt-Browser Favorites"
uintptr_t
key
=
code
&
~
KEY_MODIFIER
;
char
*
psz_key
=
malloc
(
64
);
if
(
!
psz_key
)
return
NULL
;
char
*
p
=
psz_key
,
*
psz_end
=
psz_key
+
54
;
*
p
=
'\0'
;
for
(
size_t
i
=
0
;
i
<
vlc_num_modifiers
;
i
++
)
{
if
(
i_key
&
vlc_modifiers
[
i
].
i_key_code
)
{
p
+=
snprintf
(
p
,
psz_end
-
p
,
"%s-"
,
vlc_modifiers
[
i
].
psz_key_string
);
}
}
key_descriptor_t
*
d
;
key_descriptor_t
*
d
=
bsearch
((
void
*
)
key
,
vlc_keys
,
vlc_num_keys
,
char
buf
[
5
];
i_key
&=
~
KEY_MODIFIER
;
d
=
bsearch
((
void
*
)(
uintptr_t
)
i_key
,
vlc_keys
,
vlc_num_keys
,
sizeof
(
vlc_keys
[
0
]),
cmpkey
);
sizeof
(
vlc_keys
[
0
]),
cmpkey
);
if
(
d
)
if
(
d
==
NULL
&&
utf8_cp
(
key
,
buf
)
==
NULL
)
p
+=
snprintf
(
p
,
psz_end
-
p
,
"%s"
,
d
->
psz_key_string
);
return
NULL
;
else
if
(
utf8_cp
(
i_key
,
buf
))
p
+=
snprintf
(
p
,
psz_end
-
p
,
"%s"
,
buf
);
if
(
asprintf
(
&
str
,
"%s%s%s%s%s%s"
,
else
(
code
&
KEY_MODIFIER_CTRL
)
?
"Ctrl-"
:
""
,
(
code
&
KEY_MODIFIER_ALT
)
?
"Alt-"
:
""
,
(
code
&
KEY_MODIFIER_SHIFT
)
?
"Shift-"
:
""
,
(
code
&
KEY_MODIFIER_META
)
?
"Meta-"
:
""
,
(
code
&
KEY_MODIFIER_COMMAND
)
?
"Command-"
:
""
,
(
d
!=
NULL
)
?
d
->
psz_key_string
:
buf
)
==
-
1
)
return
NULL
;
return
NULL
;
return
psz_key
;
return
str
;
}
}
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