Janne Grunau <[email protected]> writes:
> Wrapper around av_fast_malloc() that keeps FF_INPUT_BUFFER_PADDING_SIZE
> zero-padded bytes at the end of the used buffer.
>
> Based on a patch by Reimar Döffinger <[email protected]>.
> ---
> doc/APIchanges | 5 +++++
> libavcodec/avcodec.h | 9 +++++++++
> libavcodec/utils.c | 13 +++++++++++++
> libavcodec/version.h | 2 +-
> 4 files changed, 28 insertions(+), 1 deletions(-)
>
[...]
> +void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
> +{
> + uint8_t **p = ptr;
> + if (min_size > SIZE_MAX - FF_INPUT_BUFFER_PADDING_SIZE) {
> + *p = NULL;
> + *size = 0;
> + return;
> + }
> + av_fast_malloc(ptr, size, min_size + FF_INPUT_BUFFER_PADDING_SIZE);
> + if (*p)
> + memset(*p + min_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
> +}
There might be a strict aliasing problem writing the pointer as void*
(in av_fast_malloc) and reading it as uint8_t*.
--
Måns Rullgård
[email protected]
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel