Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
95c18c5d
Commit
95c18c5d
authored
Jan 25, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modules cache: refactor, no functional changes
parent
ec77bc81
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
32 deletions
+41
-32
src/modules/cache.c
src/modules/cache.c
+41
-32
No files found.
src/modules/cache.c
View file @
95c18c5d
...
@@ -80,7 +80,6 @@
...
@@ -80,7 +80,6 @@
*****************************************************************************/
*****************************************************************************/
#ifdef HAVE_DYNAMIC_PLUGINS
#ifdef HAVE_DYNAMIC_PLUGINS
static
int
CacheLoadConfig
(
module_t
*
,
FILE
*
);
static
int
CacheLoadConfig
(
module_t
*
,
FILE
*
);
static
int
CacheSaveConfig
(
module_t
*
,
FILE
*
);
/* Sub-version number
/* Sub-version number
* (only used to avoid breakage in dev version when cache structure changes) */
* (only used to avoid breakage in dev version when cache structure changes) */
...
@@ -457,7 +456,7 @@ static int CacheLoadConfig( module_t *p_module, FILE *file )
...
@@ -457,7 +456,7 @@ static int CacheLoadConfig( module_t *p_module, FILE *file )
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
static
int
CacheSave
Submodule
(
FILE
*
file
,
module_t
*
p_module
);
static
int
CacheSave
Bank
(
FILE
*
file
,
module_bank_t
*
p_bank
);
/*****************************************************************************
/*****************************************************************************
* SavePluginsCache: saves the plugins cache to a file
* SavePluginsCache: saves the plugins cache to a file
...
@@ -465,11 +464,6 @@ static int CacheSaveSubmodule( FILE *file, module_t *p_module );
...
@@ -465,11 +464,6 @@ static int CacheSaveSubmodule( FILE *file, module_t *p_module );
void
CacheSave
(
vlc_object_t
*
p_this
,
module_bank_t
*
p_bank
)
void
CacheSave
(
vlc_object_t
*
p_this
,
module_bank_t
*
p_bank
)
{
{
char
*
psz_cachedir
=
config_GetUserDir
(
VLC_CACHE_DIR
);
char
*
psz_cachedir
=
config_GetUserDir
(
VLC_CACHE_DIR
);
FILE
*
file
;
int
i
,
j
,
i_cache
;
module_cache_t
**
pp_cache
;
uint32_t
i_file_size
=
0
;
if
(
!
psz_cachedir
)
/* XXX: this should never happen */
if
(
!
psz_cachedir
)
/* XXX: this should never happen */
{
{
msg_Err
(
p_this
,
"unable to get cache directory"
);
msg_Err
(
p_this
,
"unable to get cache directory"
);
...
@@ -483,15 +477,45 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
...
@@ -483,15 +477,45 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
"%s"
DIR_SEP
CACHENAME_FORMAT
,
psz_cachedir
,
"%s"
DIR_SEP
CACHENAME_FORMAT
,
psz_cachedir
,
CACHENAME_VALUES
);
CACHENAME_VALUES
);
free
(
psz_cachedir
);
free
(
psz_cachedir
);
msg_Dbg
(
p_this
,
"writing plugins cache %s"
,
psz_filename
);
char
psz_tmpname
[
sizeof
(
psz_filename
)
+
12
];
char
psz_tmpname
[
sizeof
(
psz_filename
)
+
12
];
snprintf
(
psz_tmpname
,
sizeof
(
psz_tmpname
),
"%s.%"
PRIu32
,
psz_filename
,
snprintf
(
psz_tmpname
,
sizeof
(
psz_tmpname
),
"%s.%"
PRIu32
,
psz_filename
,
(
uint32_t
)
getpid
());
(
uint32_t
)
getpid
());
file
=
utf8_fopen
(
psz_tmpname
,
"wb"
);
FILE
*
file
=
utf8_fopen
(
psz_tmpname
,
"wb"
);
if
(
file
==
NULL
)
if
(
file
==
NULL
)
goto
error
;
goto
error
;
msg_Dbg
(
p_this
,
"writing plugins cache %s"
,
psz_filename
);
if
(
CacheSaveBank
(
file
,
p_bank
))
goto
error
;
#ifndef WIN32
utf8_rename
(
psz_tmpname
,
psz_filename
);
/* atomically replace old cache */
fclose
(
file
);
#else
utf8_unlink
(
psz_filename
);
fclose
(
file
);
utf8_rename
(
psz_tmpname
,
psz_filename
);
#endif
return
;
/* success! */
error:
msg_Warn
(
p_this
,
"could not write plugins cache %s (%m)"
,
psz_filename
);
if
(
file
!=
NULL
)
{
clearerr
(
file
);
fclose
(
file
);
}
}
static
int
CacheSaveConfig
(
FILE
*
,
module_t
*
);
static
int
CacheSaveSubmodule
(
FILE
*
,
module_t
*
);
static
int
CacheSaveBank
(
FILE
*
file
,
module_bank_t
*
p_bank
)
{
uint32_t
i_file_size
=
0
;
/* Empty space for file size */
/* Empty space for file size */
if
(
fwrite
(
&
i_file_size
,
sizeof
(
i_file_size
),
1
,
file
)
!=
1
)
if
(
fwrite
(
&
i_file_size
,
sizeof
(
i_file_size
),
1
,
file
)
!=
1
)
goto
error
;
goto
error
;
...
@@ -515,8 +539,8 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
...
@@ -515,8 +539,8 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
if
(
fwrite
(
&
i_file_size
,
sizeof
(
i_file_size
),
1
,
file
)
!=
1
)
if
(
fwrite
(
&
i_file_size
,
sizeof
(
i_file_size
),
1
,
file
)
!=
1
)
goto
error
;
goto
error
;
i_cache
=
p_bank
->
i
_cache
;
module_cache_t
**
pp_cache
=
p_bank
->
pp
_cache
;
pp_cache
=
p_bank
->
pp
_cache
;
uint32_t
i_cache
=
p_bank
->
i
_cache
;
if
(
fwrite
(
&
i_cache
,
sizeof
(
i_cache
),
1
,
file
)
!=
1
)
if
(
fwrite
(
&
i_cache
,
sizeof
(
i_cache
),
1
,
file
)
!=
1
)
goto
error
;
goto
error
;
...
@@ -532,7 +556,7 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
...
@@ -532,7 +556,7 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
goto error; \
goto error; \
} while(0)
} while(0)
for
(
i
=
0
;
i
<
i_cache
;
i
++
)
for
(
unsigned
i
=
0
;
i
<
i_cache
;
i
++
)
{
{
uint32_t
i_submodule
;
uint32_t
i_submodule
;
...
@@ -549,7 +573,7 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
...
@@ -549,7 +573,7 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
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
(
j
=
0
;
j
<
MODULE_SHORTCUT_MAX
;
j
++
)
for
(
unsigned
j
=
0
;
j
<
MODULE_SHORTCUT_MAX
;
j
++
)
{
{
SAVE_STRING
(
pp_cache
[
i
]
->
p_module
->
pp_shortcuts
[
j
]
);
// FIX
SAVE_STRING
(
pp_cache
[
i
]
->
p_module
->
pp_shortcuts
[
j
]
);
// FIX
}
}
...
@@ -559,7 +583,7 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
...
@@ -559,7 +583,7 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
SAVE_IMMEDIATE
(
pp_cache
[
i
]
->
p_module
->
b_submodule
);
SAVE_IMMEDIATE
(
pp_cache
[
i
]
->
p_module
->
b_submodule
);
/* Config stuff */
/* Config stuff */
if
(
CacheSaveConfig
(
pp_cache
[
i
]
->
p_module
,
fi
le
))
if
(
CacheSaveConfig
(
file
,
pp_cache
[
i
]
->
p_modu
le
))
goto
error
;
goto
error
;
SAVE_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_filename
);
SAVE_STRING
(
pp_cache
[
i
]
->
p_module
->
psz_filename
);
...
@@ -576,25 +600,10 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
...
@@ -576,25 +600,10 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
if
(
fwrite
(
&
i_file_size
,
sizeof
(
i_file_size
),
1
,
file
)
!=
1
if
(
fwrite
(
&
i_file_size
,
sizeof
(
i_file_size
),
1
,
file
)
!=
1
||
fflush
(
file
))
/* flush libc buffers */
||
fflush
(
file
))
/* flush libc buffers */
goto
error
;
goto
error
;
return
0
;
/* success! */
#ifndef WIN32
utf8_rename
(
psz_tmpname
,
psz_filename
);
/* atomically replace old cache */
fclose
(
file
);
#else
utf8_unlink
(
psz_filename
);
fclose
(
file
);
utf8_rename
(
psz_tmpname
,
psz_filename
);
#endif
return
;
/* success! */
error:
error:
msg_Warn
(
p_this
,
"could not write plugins cache %s (%m)"
,
return
-
1
;
psz_filename
);
if
(
file
!=
NULL
)
{
clearerr
(
file
);
fclose
(
file
);
}
}
}
static
int
CacheSaveSubmodule
(
FILE
*
file
,
module_t
*
p_module
)
static
int
CacheSaveSubmodule
(
FILE
*
file
,
module_t
*
p_module
)
...
@@ -621,7 +630,7 @@ error:
...
@@ -621,7 +630,7 @@ error:
}
}
static
int
CacheSaveConfig
(
module_t
*
p_module
,
FILE
*
file
)
static
int
CacheSaveConfig
(
FILE
*
file
,
module_t
*
p_module
)
{
{
uint32_t
i_lines
=
p_module
->
confsize
;
uint32_t
i_lines
=
p_module
->
confsize
;
...
...
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