Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
4737387d
Commit
4737387d
authored
6 years ago
by
Marton Balint
Browse files
Options
Downloads
Patches
Plain Diff
avutil/file: allow mapping 0 byte files with av_file_map
Signed-off-by:
Marton Balint
<
cus@passwd.hu
>
parent
bd3c27fd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libavutil/file.c
+8
-0
8 additions, 0 deletions
libavutil/file.c
libavutil/file.h
+2
-0
2 additions, 0 deletions
libavutil/file.h
libavutil/version.h
+1
-1
1 addition, 1 deletion
libavutil/version.h
with
11 additions
and
1 deletion
libavutil/file.c
+
8
−
0
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
...
...
This diff is collapsed.
Click to expand it.
libavutil/file.h
+
2
−
0
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
...
...
This diff is collapsed.
Click to expand it.
libavutil/version.h
+
1
−
1
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, \
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment