[FFmpeg-devel] [PATCH] make av_base64_encode return something useful

Stefano Sabatini stefano.sabatini-lala
Thu Jun 3 22:15:52 CEST 2010


On date Thursday 2010-06-03 13:11:11 -0700, Howard Chu encoded:
> Currently av_base64_encode() just returns the same pointer that was
> passed in for the output buffer. This is kind of a waste since the
> caller obviously already knows that value. Most callers of
> av_base64_encode() pretty much ignore its return value, or just
> check for NULL.
> 
> This patch changes it to return the pointer to the end of the
> result, instead of the head of the result. This allows callers to
> e.g. obtain the length of the result without a wasted call to
> strlen(), or concat new data to the string without having to
> traverse again from the beginning.
> 
> Also fixed an incorrect len passed to av_strlcat() in httpauth.c.
> Frankly this was also unnecessary since the result buffer was
> overallocated already.
> -- 
>   -- Howard Chu
>   CTO, Symas Corp.           http://www.symas.com
>   Director, Highland Sun     http://highlandsun.com/hyc/
>   Chief Architect, OpenLDAP  http://www.openldap.org/project/

> Index: libavutil/base64.c
> ===================================================================
> --- libavutil/base64.c	(revision 23437)
> +++ libavutil/base64.c	(working copy)
> @@ -65,6 +65,7 @@
>  
>  /*****************************************************************************
>  * b64_encode: Stolen from VLC's http.c.
> +* returns pointer to NUL terminator of resulting string
>  * Simplified by Michael.
>  * Fixed edge cases and made it work from data (vs. strings) by Ryan.
>  *****************************************************************************/

Uh? Documentation should go to the interface, also this change is
breaking backward compatibility, if you want that change you need to
implement a distinct function av_base64_encode2() and keep a backward
compability layer behind (eventually to be dropped at the next major
bump).

Regards.
-- 
FFmpeg = Fundamental & Fundamental Mind-dumbing Picky Ecumenical Gnome



More information about the ffmpeg-devel mailing list