[FFmpeg-devel] [PATCH] avutil/buffer: constify some function parameters

James Almer jamrial at gmail.com
Fri Sep 17 19:41:34 EEST 2021


On 9/17/2021 12:13 PM, Andreas Rheinhardt wrote:
> James Almer:
>> Signed-off-by: James Almer <jamrial at gmail.com>
>> ---
>>   libavutil/buffer.c | 6 +++---
>>   libavutil/buffer.h | 6 +++---
>>   2 files changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/libavutil/buffer.c b/libavutil/buffer.c
>> index b13eeadffb..a32b7deb89 100644
>> --- a/libavutil/buffer.c
>> +++ b/libavutil/buffer.c
>> @@ -90,7 +90,7 @@ AVBufferRef *av_buffer_allocz(size_t size)
>>       return ret;
>>   }
>>   
>> -AVBufferRef *av_buffer_ref(AVBufferRef *buf)
>> +AVBufferRef *av_buffer_ref(const AVBufferRef *buf)
>>   {
>>       AVBufferRef *ret = av_mallocz(sizeof(*ret));
>>   
>> @@ -216,7 +216,7 @@ int av_buffer_realloc(AVBufferRef **pbuf, size_t size)
>>       return 0;
>>   }
>>   
>> -int av_buffer_replace(AVBufferRef **pdst, AVBufferRef *src)
>> +int av_buffer_replace(AVBufferRef **pdst, const AVBufferRef *src)
>>   {
>>       AVBufferRef *dst = *pdst;
>>       AVBufferRef *tmp;
>> @@ -395,7 +395,7 @@ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool)
>>       return ret;
>>   }
>>   
>> -void *av_buffer_pool_buffer_get_opaque(AVBufferRef *ref)
>> +void *av_buffer_pool_buffer_get_opaque(const AVBufferRef *ref)
>>   {
>>       BufferPoolEntry *buf = ref->buffer->opaque;
>>       av_assert0(buf);
>> diff --git a/libavutil/buffer.h b/libavutil/buffer.h
>> index 2c0ce1a108..e1ef5b7f07 100644
>> --- a/libavutil/buffer.h
>> +++ b/libavutil/buffer.h
>> @@ -145,7 +145,7 @@ void av_buffer_default_free(void *opaque, uint8_t *data);
>>    * @return a new AVBufferRef referring to the same AVBuffer as buf or NULL on
>>    * failure.
>>    */
>> -AVBufferRef *av_buffer_ref(AVBufferRef *buf);
>> +AVBufferRef *av_buffer_ref(const AVBufferRef *buf);
>>   
>>   /**
>>    * Free a given reference and automatically free the buffer if there are no more
>> @@ -212,7 +212,7 @@ int av_buffer_realloc(AVBufferRef **buf, size_t size);
>>    * @return 0 on success
>>    *         AVERROR(ENOMEM) on memory allocation failure.
>>    */
>> -int av_buffer_replace(AVBufferRef **dst, AVBufferRef *src);
>> +int av_buffer_replace(AVBufferRef **dst, const AVBufferRef *src);
>>   
>>   /**
>>    * @}
>> @@ -313,7 +313,7 @@ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool);
>>    * therefore you have to use this function to access the original opaque
>>    * parameter of an allocated buffer.
>>    */
>> -void *av_buffer_pool_buffer_get_opaque(AVBufferRef *ref);
>> +void *av_buffer_pool_buffer_get_opaque(const AVBufferRef *ref);
>>   
>>   /**
>>    * @}
>>
> 
> LGTM. (Presuming that adding const to the outermost pointed-to-type is
> not considered an API break.)

Applied, thanks.


More information about the ffmpeg-devel mailing list