Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
50789e35
Commit
50789e35
authored
May 22, 2019
by
Gyan Doshi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/cache - delete cache file after closing handle
Verified that cache files get deleted on Windows.
parent
a6818d5b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
cache.c
libavformat/cache.c
+15
-2
No files found.
libavformat/cache.c
View file @
50789e35
...
@@ -54,6 +54,7 @@ typedef struct CacheEntry {
...
@@ -54,6 +54,7 @@ typedef struct CacheEntry {
typedef
struct
Context
{
typedef
struct
Context
{
AVClass
*
class
;
AVClass
*
class
;
int
fd
;
int
fd
;
char
*
filename
;
struct
AVTreeNode
*
root
;
struct
AVTreeNode
*
root
;
int64_t
logical_pos
;
int64_t
logical_pos
;
int64_t
cache_pos
;
int64_t
cache_pos
;
...
@@ -72,6 +73,7 @@ static int cmp(const void *key, const void *node)
...
@@ -72,6 +73,7 @@ static int cmp(const void *key, const void *node)
static
int
cache_open
(
URLContext
*
h
,
const
char
*
arg
,
int
flags
,
AVDictionary
**
options
)
static
int
cache_open
(
URLContext
*
h
,
const
char
*
arg
,
int
flags
,
AVDictionary
**
options
)
{
{
int
ret
;
char
*
buffername
;
char
*
buffername
;
Context
*
c
=
h
->
priv_data
;
Context
*
c
=
h
->
priv_data
;
...
@@ -83,8 +85,12 @@ static int cache_open(URLContext *h, const char *arg, int flags, AVDictionary **
...
@@ -83,8 +85,12 @@ static int cache_open(URLContext *h, const char *arg, int flags, AVDictionary **
return
c
->
fd
;
return
c
->
fd
;
}
}
unlink
(
buffername
);
ret
=
unlink
(
buffername
);
av_freep
(
&
buffername
);
if
(
ret
>=
0
)
av_freep
(
&
buffername
);
else
c
->
filename
=
buffername
;
return
ffurl_open_whitelist
(
&
c
->
inner
,
arg
,
flags
,
&
h
->
interrupt_callback
,
return
ffurl_open_whitelist
(
&
c
->
inner
,
arg
,
flags
,
&
h
->
interrupt_callback
,
options
,
h
->
protocol_whitelist
,
h
->
protocol_blacklist
,
h
);
options
,
h
->
protocol_whitelist
,
h
->
protocol_blacklist
,
h
);
...
@@ -292,11 +298,18 @@ static int enu_free(void *opaque, void *elem)
...
@@ -292,11 +298,18 @@ static int enu_free(void *opaque, void *elem)
static
int
cache_close
(
URLContext
*
h
)
static
int
cache_close
(
URLContext
*
h
)
{
{
Context
*
c
=
h
->
priv_data
;
Context
*
c
=
h
->
priv_data
;
int
ret
;
av_log
(
h
,
AV_LOG_INFO
,
"Statistics, cache hits:%"
PRId64
" cache misses:%"
PRId64
"
\n
"
,
av_log
(
h
,
AV_LOG_INFO
,
"Statistics, cache hits:%"
PRId64
" cache misses:%"
PRId64
"
\n
"
,
c
->
cache_hit
,
c
->
cache_miss
);
c
->
cache_hit
,
c
->
cache_miss
);
close
(
c
->
fd
);
close
(
c
->
fd
);
if
(
c
->
filename
)
{
ret
=
unlink
(
c
->
filename
);
if
(
ret
<
0
)
av_log
(
h
,
AV_LOG_ERROR
,
"Could not delete %s.
\n
"
,
c
->
filename
);
av_freep
(
&
c
->
filename
);
}
ffurl_close
(
c
->
inner
);
ffurl_close
(
c
->
inner
);
av_tree_enumerate
(
c
->
root
,
NULL
,
NULL
,
enu_free
);
av_tree_enumerate
(
c
->
root
,
NULL
,
NULL
,
enu_free
);
av_tree_destroy
(
c
->
root
);
av_tree_destroy
(
c
->
root
);
...
...
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