Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
c36ef0c8
Commit
c36ef0c8
authored
Jan 03, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Variable lookup: small code factorization
parent
33755a28
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
src/misc/variables.c
src/misc/variables.c
+14
-13
No files found.
src/misc/variables.c
View file @
c36ef0c8
...
...
@@ -156,7 +156,7 @@ static int GetUnused ( vlc_object_t *, const char * );
static
uint32_t
HashString
(
const
char
*
);
static
int
Insert
(
variable_t
**
,
int
,
const
char
*
);
static
int
InsertInner
(
variable_t
**
,
int
,
uint32_t
);
static
int
Lookup
(
v
ariable_t
*
const
*
,
size_t
,
const
char
*
);
static
int
Lookup
(
v
lc_object_t
*
,
const
char
*
);
static
void
CheckValue
(
variable_t
*
,
vlc_value_t
*
);
...
...
@@ -291,7 +291,7 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
* duplicate the lookups. It's not that serious, but if anyone finds some
* time to rework Insert() so that only one lookup has to be done, feel
* free to do so. */
i_new
=
Lookup
(
p_
priv
->
pp_vars
,
p_priv
->
i_var
s
,
psz_name
);
i_new
=
Lookup
(
p_
thi
s
,
psz_name
);
if
(
i_new
>=
0
)
{
...
...
@@ -414,7 +414,7 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
vlc_mutex_lock
(
&
p_priv
->
var_lock
);
i_var
=
Lookup
(
p_
priv
->
pp_vars
,
p_priv
->
i_var
s
,
psz_name
);
i_var
=
Lookup
(
p_
thi
s
,
psz_name
);
if
(
i_var
<
0
)
{
...
...
@@ -713,7 +713,7 @@ int __var_Type( vlc_object_t *p_this, const char *psz_name )
vlc_mutex_lock
(
&
p_priv
->
var_lock
);
i_var
=
Lookup
(
p_
priv
->
pp_vars
,
p_priv
->
i_var
s
,
psz_name
);
i_var
=
Lookup
(
p_
thi
s
,
psz_name
);
if
(
i_var
<
0
)
{
...
...
@@ -799,7 +799,7 @@ int var_GetChecked( vlc_object_t *p_this, const char *psz_name,
vlc_mutex_lock
(
&
p_priv
->
var_lock
);
i_var
=
Lookup
(
p_
priv
->
pp_vars
,
p_priv
->
i_var
s
,
psz_name
);
i_var
=
Lookup
(
p_
thi
s
,
psz_name
);
if
(
i_var
>=
0
)
{
variable_t
*
p_var
=
p_priv
->
pp_vars
[
i_var
];
...
...
@@ -1153,7 +1153,7 @@ static int GetUnused( vlc_object_t *p_this, const char *psz_name )
{
int
i_var
;
i_var
=
Lookup
(
p_
priv
->
pp_vars
,
p_priv
->
i_var
s
,
psz_name
);
i_var
=
Lookup
(
p_
thi
s
,
psz_name
);
if
(
i_var
<
0
)
{
return
VLC_ENOVAR
;
...
...
@@ -1260,20 +1260,21 @@ static int u32cmp( const void *key, const void *data )
* We use a recursive inner function indexed on the hash. Care is taken of
* possible hash collisions.
*****************************************************************************/
static
int
Lookup
(
variable_t
*
const
*
pp_vars
,
size_t
i_count
,
const
char
*
psz_name
)
static
int
Lookup
(
vlc_object_t
*
obj
,
const
char
*
psz_name
)
{
vlc_object_internals_t
*
priv
=
vlc_internals
(
obj
);
variable_t
**
pp_vars
=
priv
->
pp_vars
;
size_t
i_vars
=
priv
->
i_vars
;
variable_t
**
pp_var
;
uint32_t
i_hash
;
uint32_t
i_hash
=
HashString
(
psz_name
)
;
i_hash
=
HashString
(
psz_name
);
pp_var
=
bsearch
(
&
i_hash
,
pp_vars
,
i_count
,
sizeof
(
*
pp_var
),
u32cmp
);
pp_var
=
bsearch
(
&
i_hash
,
pp_vars
,
i_vars
,
sizeof
(
*
pp_var
),
u32cmp
);
/* Hash not found */
if
(
pp_var
==
NULL
)
return
-
1
;
assert
(
i_
count
>
0
);
assert
(
i_
vars
>
0
);
/* Find the first entry with the right hash */
while
(
(
pp_var
>
pp_vars
)
&&
(
i_hash
==
pp_var
[
-
1
]
->
i_hash
)
)
...
...
@@ -1284,7 +1285,7 @@ static int Lookup( variable_t *const *pp_vars, size_t i_count,
/* Hash collision should be very unlikely, but we cannot guarantee
* it will never happen. So we do an exhaustive search amongst all
* entries with the same hash. Typically, there is only one anyway. */
for
(
variable_t
*
const
*
p_end
=
pp_vars
+
i_
count
;
for
(
variable_t
*
const
*
p_end
=
pp_vars
+
i_
vars
;
(
pp_var
<
p_end
)
&&
(
i_hash
==
(
*
pp_var
)
->
i_hash
);
pp_var
++
)
{
...
...
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