Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
786be70e
Commit
786be70e
authored
May 23, 2021
by
James Almer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avutil/mem: make ff_fast_malloc() internal to mem.c
Signed-off-by:
James Almer
<
jamrial@gmail.com
>
parent
e44cb736
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
20 deletions
+21
-20
mem.c
libavutil/mem.c
+21
-2
mem_internal.h
libavutil/mem_internal.h
+0
-18
No files found.
libavutil/mem.c
View file @
786be70e
...
...
@@ -510,12 +510,31 @@ void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
return
ptr
;
}
static
inline
void
fast_malloc
(
void
*
ptr
,
unsigned
int
*
size
,
size_t
min_size
,
int
zero_realloc
)
{
void
*
val
;
memcpy
(
&
val
,
ptr
,
sizeof
(
val
));
if
(
min_size
<=
*
size
)
{
av_assert0
(
val
||
!
min_size
);
return
;
}
min_size
=
FFMAX
(
min_size
+
min_size
/
16
+
32
,
min_size
);
av_freep
(
ptr
);
val
=
zero_realloc
?
av_mallocz
(
min_size
)
:
av_malloc
(
min_size
);
memcpy
(
ptr
,
&
val
,
sizeof
(
val
));
if
(
!
val
)
min_size
=
0
;
*
size
=
min_size
;
return
;
}
void
av_fast_malloc
(
void
*
ptr
,
unsigned
int
*
size
,
size_t
min_size
)
{
f
f_f
ast_malloc
(
ptr
,
size
,
min_size
,
0
);
fast_malloc
(
ptr
,
size
,
min_size
,
0
);
}
void
av_fast_mallocz
(
void
*
ptr
,
unsigned
int
*
size
,
size_t
min_size
)
{
f
f_f
ast_malloc
(
ptr
,
size
,
min_size
,
1
);
fast_malloc
(
ptr
,
size
,
min_size
,
1
);
}
libavutil/mem_internal.h
View file @
786be70e
...
...
@@ -136,22 +136,4 @@
# define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_A(32, t, v, __VA_ARGS__,,))
#endif
static
inline
int
ff_fast_malloc
(
void
*
ptr
,
unsigned
int
*
size
,
size_t
min_size
,
int
zero_realloc
)
{
void
*
val
;
memcpy
(
&
val
,
ptr
,
sizeof
(
val
));
if
(
min_size
<=
*
size
)
{
av_assert0
(
val
||
!
min_size
);
return
0
;
}
min_size
=
FFMAX
(
min_size
+
min_size
/
16
+
32
,
min_size
);
av_freep
(
ptr
);
val
=
zero_realloc
?
av_mallocz
(
min_size
)
:
av_malloc
(
min_size
);
memcpy
(
ptr
,
&
val
,
sizeof
(
val
));
if
(
!
val
)
min_size
=
0
;
*
size
=
min_size
;
return
1
;
}
#endif
/* AVUTIL_MEM_INTERNAL_H */
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