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
0b574db7
Commit
0b574db7
authored
Apr 22, 2010
by
Rémi Duraffort
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Second attempt to use a dynamic array shortcuts (this save some memory).
parent
127a34f1
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
50 deletions
+66
-50
src/libvlc.c
src/libvlc.c
+11
-12
src/modules/cache.c
src/modules/cache.c
+31
-10
src/modules/entry.c
src/modules/entry.c
+12
-10
src/modules/modules.c
src/modules/modules.c
+8
-15
src/modules/modules.h
src/modules/modules.h
+4
-3
No files found.
src/libvlc.c
View file @
0b574db7
...
@@ -1423,15 +1423,15 @@ static void Usage( libvlc_int_t *p_this, char const *psz_search )
...
@@ -1423,15 +1423,15 @@ static void Usage( libvlc_int_t *p_this, char const *psz_search )
(
b_strict
?
strcmp
(
psz_search
,
p_parser
->
psz_object_name
)
(
b_strict
?
strcmp
(
psz_search
,
p_parser
->
psz_object_name
)
:
!
strstr
(
p_parser
->
psz_object_name
,
psz_search
)
)
)
:
!
strstr
(
p_parser
->
psz_object_name
,
psz_search
)
)
)
{
{
char
*
const
*
pp_shortcut
=
p_parser
->
pp_shortcuts
;
char
*
const
*
pp_shortcuts
=
p_parser
->
pp_shortcuts
;
while
(
*
pp_shortcut
)
int
i
;
for
(
i
=
0
;
i
<
p_parser
->
i_shortcuts
;
i
++
)
{
{
if
(
b_strict
?
!
strcmp
(
psz_search
,
*
pp_shortcut
)
if
(
b_strict
?
!
strcmp
(
psz_search
,
pp_shortcuts
[
i
]
)
:
!!
strstr
(
*
pp_shortcut
,
psz_search
)
)
:
!!
strstr
(
pp_shortcuts
[
i
]
,
psz_search
)
)
break
;
break
;
pp_shortcut
++
;
}
}
if
(
!*
pp_shortcut
)
if
(
i
==
p_parser
->
i_shortcuts
)
continue
;
continue
;
}
}
...
@@ -1861,19 +1861,18 @@ static void ListModules( libvlc_int_t *p_this, bool b_verbose )
...
@@ -1861,19 +1861,18 @@ static void ListModules( libvlc_int_t *p_this, bool b_verbose )
if
(
b_verbose
)
if
(
b_verbose
)
{
{
char
*
const
*
pp_shortcut
=
p_parser
->
pp_shortcuts
;
char
*
const
*
pp_shortcut
s
=
p_parser
->
pp_shortcuts
;
while
(
*
pp_shortcut
)
for
(
int
i
=
0
;
i
<
p_parser
->
i_shortcuts
;
i
++
)
{
{
if
(
strcmp
(
*
pp_shortcut
,
p_parser
->
psz_object_name
)
)
if
(
strcmp
(
pp_shortcuts
[
i
]
,
p_parser
->
psz_object_name
)
)
{
{
if
(
b_color
)
if
(
b_color
)
utf8_fprintf
(
stdout
,
CYAN
" s %s
\n
"
GRAY
,
utf8_fprintf
(
stdout
,
CYAN
" s %s
\n
"
GRAY
,
*
pp_shortcut
);
pp_shortcuts
[
i
]
);
else
else
utf8_fprintf
(
stdout
,
" s %s
\n
"
,
utf8_fprintf
(
stdout
,
" s %s
\n
"
,
*
pp_shortcut
);
pp_shortcuts
[
i
]
);
}
}
pp_shortcut
++
;
}
}
if
(
p_parser
->
psz_capability
)
if
(
p_parser
->
psz_capability
)
{
{
...
...
src/modules/cache.c
View file @
0b574db7
...
@@ -253,10 +253,20 @@ void CacheLoad( vlc_object_t *p_this, module_bank_t *p_bank, const char *dir )
...
@@ -253,10 +253,20 @@ void CacheLoad( vlc_object_t *p_this, module_bank_t *p_bank, const char *dir )
LOAD_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_shortname
);
LOAD_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_shortname
);
LOAD_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_longname
);
LOAD_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_longname
);
LOAD_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_help
);
LOAD_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_help
);
for
(
j
=
0
;
j
<
MODULE_SHORTCUT_MAX
;
j
++
)
LOAD_IMMEDIATE
(
pp_cache
[
i
]
->
p_module
->
i_shortcuts
);
if
(
pp_cache
[
i
]
->
p_module
->
i_shortcuts
>
MODULE_SHORTCUT_MAX
)
goto
error
;
else
if
(
pp_cache
[
i
]
->
p_module
->
i_shortcuts
==
0
)
pp_cache
[
i
]
->
p_module
->
pp_shortcuts
=
NULL
;
else
{
{
LOAD_STRING
(
pp_cache
[
i
]
->
p_module
->
pp_shortcuts
[
j
]
);
// FIX
pp_cache
[
i
]
->
p_module
->
pp_shortcuts
=
xmalloc
(
sizeof
(
char
**
)
*
pp_cache
[
i
]
->
p_module
->
i_shortcuts
);
for
(
j
=
0
;
j
<
pp_cache
[
i
]
->
p_module
->
i_shortcuts
;
j
++
)
LOAD_STRING
(
pp_cache
[
i
]
->
p_module
->
pp_shortcuts
[
j
]
);
}
}
LOAD_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_capability
);
LOAD_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_capability
);
LOAD_IMMEDIATE
(
pp_cache
[
i
]
->
p_module
->
i_score
);
LOAD_IMMEDIATE
(
pp_cache
[
i
]
->
p_module
->
i_score
);
LOAD_IMMEDIATE
(
pp_cache
[
i
]
->
p_module
->
b_unloadable
);
LOAD_IMMEDIATE
(
pp_cache
[
i
]
->
p_module
->
b_unloadable
);
...
@@ -277,14 +287,24 @@ void CacheLoad( vlc_object_t *p_this, module_bank_t *p_bank, const char *dir )
...
@@ -277,14 +287,24 @@ void CacheLoad( vlc_object_t *p_this, module_bank_t *p_bank, const char *dir )
{
{
module_t
*
p_module
=
vlc_submodule_create
(
pp_cache
[
i
]
->
p_module
);
module_t
*
p_module
=
vlc_submodule_create
(
pp_cache
[
i
]
->
p_module
);
free
(
p_module
->
psz_object_name
);
free
(
p_module
->
psz_object_name
);
free
(
p_module
->
pp_shortcuts
);
LOAD_STRING
(
p_module
->
psz_object_name
);
LOAD_STRING
(
p_module
->
psz_object_name
);
LOAD_STRING
(
p_module
->
psz_shortname
);
LOAD_STRING
(
p_module
->
psz_shortname
);
LOAD_STRING
(
p_module
->
psz_longname
);
LOAD_STRING
(
p_module
->
psz_longname
);
LOAD_STRING
(
p_module
->
psz_help
);
LOAD_STRING
(
p_module
->
psz_help
);
for
(
j
=
0
;
j
<
MODULE_SHORTCUT_MAX
;
j
++
)
LOAD_IMMEDIATE
(
p_module
->
i_shortcuts
);
if
(
p_module
->
i_shortcuts
>
MODULE_SHORTCUT_MAX
)
goto
error
;
else
if
(
p_module
->
i_shortcuts
==
0
)
p_module
->
pp_shortcuts
=
NULL
;
else
{
{
LOAD_STRING
(
p_module
->
pp_shortcuts
[
j
]
);
// FIX
p_module
->
pp_shortcuts
=
xmalloc
(
sizeof
(
char
**
)
*
p_module
->
i_shortcuts
);
for
(
j
=
0
;
j
<
p_module
->
i_shortcuts
;
j
++
)
LOAD_STRING
(
p_module
->
pp_shortcuts
[
j
]
);
}
}
LOAD_STRING
(
p_module
->
psz_capability
);
LOAD_STRING
(
p_module
->
psz_capability
);
LOAD_IMMEDIATE
(
p_module
->
i_score
);
LOAD_IMMEDIATE
(
p_module
->
i_score
);
LOAD_IMMEDIATE
(
p_module
->
b_unloadable
);
LOAD_IMMEDIATE
(
p_module
->
b_unloadable
);
...
@@ -545,10 +565,10 @@ static int CacheSaveBank (FILE *file, module_cache_t *const *pp_cache,
...
@@ -545,10 +565,10 @@ static int CacheSaveBank (FILE *file, module_cache_t *const *pp_cache,
SAVE_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_shortname
);
SAVE_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_shortname
);
SAVE_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_longname
);
SAVE_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_longname
);
SAVE_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_help
);
SAVE_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_help
);
for
(
unsigned
j
=
0
;
j
<
MODULE_SHORTCUT_MAX
;
j
++
)
SAVE_IMMEDIATE
(
pp_cache
[
i
]
->
p_module
->
i_shortcuts
);
{
for
(
unsigned
j
=
0
;
j
<
pp_cache
[
i
]
->
p_module
->
i_shortcuts
;
j
++
)
SAVE_STRING
(
pp_cache
[
i
]
->
p_module
->
pp_shortcuts
[
j
]
);
// FIX
SAVE_STRING
(
pp_cache
[
i
]
->
p_module
->
pp_shortcuts
[
j
]
);
}
SAVE_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_capability
);
SAVE_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_capability
);
SAVE_IMMEDIATE
(
pp_cache
[
i
]
->
p_module
->
i_score
);
SAVE_IMMEDIATE
(
pp_cache
[
i
]
->
p_module
->
i_score
);
SAVE_IMMEDIATE
(
pp_cache
[
i
]
->
p_module
->
b_unloadable
);
SAVE_IMMEDIATE
(
pp_cache
[
i
]
->
p_module
->
b_unloadable
);
...
@@ -590,8 +610,9 @@ static int CacheSaveSubmodule( FILE *file, const module_t *p_module )
...
@@ -590,8 +610,9 @@ static int CacheSaveSubmodule( FILE *file, const module_t *p_module )
SAVE_STRING
(
p_module
->
psz_shortname
);
SAVE_STRING
(
p_module
->
psz_shortname
);
SAVE_STRING
(
p_module
->
psz_longname
);
SAVE_STRING
(
p_module
->
psz_longname
);
SAVE_STRING
(
p_module
->
psz_help
);
SAVE_STRING
(
p_module
->
psz_help
);
for
(
unsigned
j
=
0
;
j
<
MODULE_SHORTCUT_MAX
;
j
++
)
SAVE_IMMEDIATE
(
p_module
->
i_shortcuts
);
SAVE_STRING
(
p_module
->
pp_shortcuts
[
j
]
);
// FIXME
for
(
unsigned
j
=
0
;
j
<
p_module
->
i_shortcuts
;
j
++
)
SAVE_STRING
(
p_module
->
pp_shortcuts
[
j
]
);
SAVE_STRING
(
p_module
->
psz_capability
);
SAVE_STRING
(
p_module
->
psz_capability
);
SAVE_IMMEDIATE
(
p_module
->
i_score
);
SAVE_IMMEDIATE
(
p_module
->
i_score
);
...
...
src/modules/entry.c
View file @
0b574db7
...
@@ -37,6 +37,7 @@ static void vlc_module_destruct (gc_object_t *obj)
...
@@ -37,6 +37,7 @@ static void vlc_module_destruct (gc_object_t *obj)
{
{
module_t
*
module
=
vlc_priv
(
obj
,
module_t
);
module_t
*
module
=
vlc_priv
(
obj
,
module_t
);
free
(
module
->
pp_shortcuts
);
free
(
module
->
psz_object_name
);
free
(
module
->
psz_object_name
);
free
(
module
);
free
(
module
);
}
}
...
@@ -59,8 +60,8 @@ module_t *vlc_module_create (vlc_object_t *obj)
...
@@ -59,8 +60,8 @@ module_t *vlc_module_create (vlc_object_t *obj)
module
->
psz_shortname
=
NULL
;
module
->
psz_shortname
=
NULL
;
module
->
psz_longname
=
(
char
*
)
default_name
;
module
->
psz_longname
=
(
char
*
)
default_name
;
module
->
psz_help
=
NULL
;
module
->
psz_help
=
NULL
;
for
(
unsigned
i
=
0
;
i
<
MODULE_SHORTCUT_MAX
;
i
++
)
module
->
pp_shortcuts
=
NULL
;
module
->
pp_shortcuts
[
i
]
=
NULL
;
module
->
i_shortcuts
=
0
;
module
->
psz_capability
=
(
char
*
)
""
;
module
->
psz_capability
=
(
char
*
)
""
;
module
->
i_score
=
1
;
module
->
i_score
=
1
;
module
->
b_unloadable
=
true
;
module
->
b_unloadable
=
true
;
...
@@ -85,6 +86,7 @@ module_t *vlc_module_create (vlc_object_t *obj)
...
@@ -85,6 +86,7 @@ module_t *vlc_module_create (vlc_object_t *obj)
static
void
vlc_submodule_destruct
(
gc_object_t
*
obj
)
static
void
vlc_submodule_destruct
(
gc_object_t
*
obj
)
{
{
module_t
*
module
=
vlc_priv
(
obj
,
module_t
);
module_t
*
module
=
vlc_priv
(
obj
,
module_t
);
free
(
module
->
pp_shortcuts
);
free
(
module
->
psz_object_name
);
free
(
module
->
psz_object_name
);
free
(
module
);
free
(
module
);
}
}
...
@@ -105,9 +107,9 @@ module_t *vlc_submodule_create (module_t *module)
...
@@ -105,9 +107,9 @@ module_t *vlc_submodule_create (module_t *module)
module
->
submodule_count
++
;
module
->
submodule_count
++
;
/* Muahahaha! Heritage! Polymorphism! Ugliness!! */
/* Muahahaha! Heritage! Polymorphism! Ugliness!! */
submodule
->
pp_shortcuts
=
malloc
(
sizeof
(
char
**
)
);
submodule
->
pp_shortcuts
[
0
]
=
module
->
pp_shortcuts
[
0
];
/* object name */
submodule
->
pp_shortcuts
[
0
]
=
module
->
pp_shortcuts
[
0
];
/* object name */
for
(
unsigned
i
=
1
;
i
<
MODULE_SHORTCUT_MAX
;
i
++
)
submodule
->
i_shortcuts
=
1
;
submodule
->
pp_shortcuts
[
i
]
=
NULL
;
submodule
->
psz_object_name
=
strdup
(
module
->
psz_object_name
);
submodule
->
psz_object_name
=
strdup
(
module
->
psz_object_name
);
submodule
->
psz_shortname
=
module
->
psz_shortname
;
submodule
->
psz_shortname
=
module
->
psz_shortname
;
...
@@ -179,12 +181,9 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
...
@@ -179,12 +181,9 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
case
VLC_MODULE_SHORTCUT
:
case
VLC_MODULE_SHORTCUT
:
{
{
unsigned
i
;
const
char
*
psz_new
=
va_arg
(
ap
,
char
*
);
for
(
i
=
0
;
module
->
pp_shortcuts
[
i
]
!=
NULL
;
i
++
);
module
->
pp_shortcuts
=
realloc
(
module
->
pp_shortcuts
,
sizeof
(
char
**
)
*
(
module
->
i_shortcuts
+
1
));
if
(
i
>=
(
MODULE_SHORTCUT_MAX
-
1
))
module
->
pp_shortcuts
[
module
->
i_shortcuts
++
]
=
psz_new
;
break
;
module
->
pp_shortcuts
[
i
]
=
va_arg
(
ap
,
char
*
);
break
;
break
;
}
}
...
@@ -213,7 +212,10 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
...
@@ -213,7 +212,10 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
const
char
*
value
=
va_arg
(
ap
,
const
char
*
);
const
char
*
value
=
va_arg
(
ap
,
const
char
*
);
free
(
module
->
psz_object_name
);
free
(
module
->
psz_object_name
);
module
->
psz_object_name
=
strdup
(
value
);
module
->
psz_object_name
=
strdup
(
value
);
module
->
pp_shortcuts
=
malloc
(
sizeof
(
char
**
)
);
module
->
pp_shortcuts
[
0
]
=
(
char
*
)
value
;
/* dooh! */
module
->
pp_shortcuts
[
0
]
=
(
char
*
)
value
;
/* dooh! */
module
->
i_shortcuts
=
1
;
if
(
module
->
psz_longname
==
default_name
)
if
(
module
->
psz_longname
==
default_name
)
module
->
psz_longname
=
(
char
*
)
value
;
/* dooh! */
module
->
psz_longname
=
(
char
*
)
value
;
/* dooh! */
break
;
break
;
...
...
src/modules/modules.c
View file @
0b574db7
...
@@ -481,7 +481,7 @@ module_t * module_need( vlc_object_t *p_this, const char *psz_capability,
...
@@ -481,7 +481,7 @@ module_t * module_need( vlc_object_t *p_this, const char *psz_capability,
for
(
unsigned
i_short
=
i_shortcuts
;
i_short
>
0
;
i_short
--
)
for
(
unsigned
i_short
=
i_shortcuts
;
i_short
>
0
;
i_short
--
)
{
{
for
(
unsigned
i
=
0
;
p_module
->
pp_shortcuts
[
i
]
;
i
++
)
for
(
unsigned
i
=
0
;
i
<
p_module
->
i_shortcuts
;
i
++
)
{
{
char
*
c
;
char
*
c
;
if
(
(
c
=
strchr
(
name
,
'@'
)
)
if
(
(
c
=
strchr
(
name
,
'@'
)
)
...
@@ -691,9 +691,7 @@ module_t *module_find_by_shortcut (const char *psz_shortcut)
...
@@ -691,9 +691,7 @@ module_t *module_find_by_shortcut (const char *psz_shortcut)
for
(
size_t
i
=
0
;
(
module
=
list
[
i
])
!=
NULL
;
i
++
)
for
(
size_t
i
=
0
;
(
module
=
list
[
i
])
!=
NULL
;
i
++
)
{
{
for
(
size_t
j
=
0
;
for
(
size_t
j
=
0
;
j
<
module
->
i_shortcuts
;
j
++
)
(
module
->
pp_shortcuts
[
j
]
!=
NULL
)
&&
(
j
<
MODULE_SHORTCUT_MAX
);
j
++
)
{
{
if
(
!
strcmp
(
module
->
pp_shortcuts
[
j
],
psz_shortcut
))
if
(
!
strcmp
(
module
->
pp_shortcuts
[
j
],
psz_shortcut
))
{
{
...
@@ -1054,12 +1052,9 @@ static module_t * AllocatePlugin( vlc_object_t * p_this, const char *psz_file )
...
@@ -1054,12 +1052,9 @@ static module_t * AllocatePlugin( vlc_object_t * p_this, const char *psz_file )
*****************************************************************************/
*****************************************************************************/
static
void
DupModule
(
module_t
*
p_module
)
static
void
DupModule
(
module_t
*
p_module
)
{
{
char
**
pp_shortcut
;
char
**
pp_shortcuts
=
p_module
->
pp_shortcuts
;
for
(
unsigned
i
=
0
;
i
<
p_module
->
i_shortcuts
;
i
++
)
for
(
pp_shortcut
=
p_module
->
pp_shortcuts
;
*
pp_shortcut
;
pp_shortcut
++
)
pp_shortcuts
[
i
]
=
strdup
(
p_module
->
pp_shortcuts
[
i
]
);
{
*
pp_shortcut
=
strdup
(
*
pp_shortcut
);
}
/* We strdup() these entries so that they are still valid when the
/* We strdup() these entries so that they are still valid when the
* module is unloaded. */
* module is unloaded. */
...
@@ -1082,15 +1077,13 @@ static void DupModule( module_t *p_module )
...
@@ -1082,15 +1077,13 @@ static void DupModule( module_t *p_module )
*****************************************************************************/
*****************************************************************************/
static
void
UndupModule
(
module_t
*
p_module
)
static
void
UndupModule
(
module_t
*
p_module
)
{
{
char
**
pp_shortcut
;
char
**
pp_shortcut
s
=
p_module
->
pp_shortcuts
;
for
(
module_t
*
subm
=
p_module
->
submodule
;
subm
;
subm
=
subm
->
next
)
for
(
module_t
*
subm
=
p_module
->
submodule
;
subm
;
subm
=
subm
->
next
)
UndupModule
(
subm
);
UndupModule
(
subm
);
for
(
pp_shortcut
=
p_module
->
pp_shortcuts
;
*
pp_shortcut
;
pp_shortcut
++
)
for
(
unsigned
i
=
0
;
i
<
p_module
->
i_shortcuts
;
i
++
)
{
free
(
pp_shortcuts
[
i
]
);
free
(
*
pp_shortcut
);
}
free
(
p_module
->
psz_capability
);
free
(
p_module
->
psz_capability
);
FREENULL
(
p_module
->
psz_shortname
);
FREENULL
(
p_module
->
psz_shortname
);
...
...
src/modules/modules.h
View file @
0b574db7
...
@@ -100,6 +100,10 @@ struct module_t
...
@@ -100,6 +100,10 @@ struct module_t
module_t
*
submodule
;
module_t
*
submodule
;
unsigned
submodule_count
;
unsigned
submodule_count
;
/** Shortcuts to the module */
unsigned
i_shortcuts
;
char
**
pp_shortcuts
;
/*
/*
* Variables set by the module to identify itself
* Variables set by the module to identify itself
*/
*/
...
@@ -107,9 +111,6 @@ struct module_t
...
@@ -107,9 +111,6 @@ struct module_t
char
*
psz_longname
;
/**< Module descriptive name */
char
*
psz_longname
;
/**< Module descriptive name */
char
*
psz_help
;
/**< Long help string for "special" modules */
char
*
psz_help
;
/**< Long help string for "special" modules */
/** Shortcuts to the module */
char
*
pp_shortcuts
[
MODULE_SHORTCUT_MAX
];
char
*
psz_capability
;
/**< Capability */
char
*
psz_capability
;
/**< Capability */
int
i_score
;
/**< Score for the capability */
int
i_score
;
/**< Score for the capability */
...
...
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