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
4737387d
Commit
4737387d
authored
Sep 06, 2018
by
Marton Balint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avutil/file: allow mapping 0 byte files with av_file_map
Signed-off-by:
Marton Balint
<
cus@passwd.hu
>
parent
bd3c27fd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
1 deletion
+11
-1
file.c
libavutil/file.c
+8
-0
file.h
libavutil/file.h
+2
-0
version.h
libavutil/version.h
+1
-1
No files found.
libavutil/file.c
View file @
4737387d
...
...
@@ -85,6 +85,11 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
}
*
size
=
off_size
;
if
(
!*
size
)
{
*
bufptr
=
NULL
;
goto
out
;
}
#if HAVE_MMAP
ptr
=
mmap
(
NULL
,
*
size
,
PROT_READ
|
PROT_WRITE
,
MAP_PRIVATE
,
fd
,
0
);
if
(
ptr
==
MAP_FAILED
)
{
...
...
@@ -126,12 +131,15 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
read
(
fd
,
*
bufptr
,
*
size
);
#endif
out:
close
(
fd
);
return
0
;
}
void
av_file_unmap
(
uint8_t
*
bufptr
,
size_t
size
)
{
if
(
!
size
)
return
;
#if HAVE_MMAP
munmap
(
bufptr
,
size
);
#elif HAVE_MAPVIEWOFFILE
...
...
libavutil/file.h
View file @
4737387d
...
...
@@ -33,6 +33,8 @@
* allocated buffer or map it with mmap() when available.
* In case of success set *bufptr to the read or mmapped buffer, and
* *size to the size in bytes of the buffer in *bufptr.
* Unlike mmap this function succeeds with zero sized files, in this
* case *bufptr will be set to NULL and *size will be set to 0.
* The returned buffer must be released with av_file_unmap().
*
* @param log_offset loglevel offset used for logging
...
...
libavutil/version.h
View file @
4737387d
...
...
@@ -80,7 +80,7 @@
#define LIBAVUTIL_VERSION_MAJOR 56
#define LIBAVUTIL_VERSION_MINOR 19
#define LIBAVUTIL_VERSION_MICRO 10
0
#define LIBAVUTIL_VERSION_MICRO 10
1
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
...
...
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