[FFmpeg-devel] [PATCH 1/2] avio: add avio_get_str()

Måns Rullgård mans
Wed Mar 2 19:41:34 CET 2011


Anton Khirnov <anton at khirnov.net> writes:

> From: Reimar D?ffinger <Reimar.Doeffinger at gmx.de>
>
> ---
>  libavformat/avio.h    |   12 ++++++++++++
>  libavformat/aviobuf.c |   17 +++++++++++++++++
>  2 files changed, 29 insertions(+), 0 deletions(-)
>
> diff --git a/libavformat/avio.h b/libavformat/avio.h
> index cc46ad7..912ab0b 100644
> --- a/libavformat/avio.h
> +++ b/libavformat/avio.h
> @@ -526,6 +526,18 @@ unsigned int avio_rl32(AVIOContext *s);
>  uint64_t     avio_rl64(AVIOContext *s);
>  
>  /**
> + * Read a string from pb into buf. The reading will terminate when either
> + * a NULL character was encountered or maxlen bytes have been read. The
> + * result is guaranteed to be NULL-terminated, it will be truncated if buf
> + * is too small.
> + * Note that the string is not interpreted or validated in any way, it
> + * might get truncated in the middle of a sequence for multi-byte encodings.
> + *
> + * @return number of bytes read (is always <= maxlen).
> + */
> +int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);

What is the purpose of passing both maxlen and buflen?  The caller can
simply use whichever is smaller.

Is the return value the number of bytes read or the number of bytes
stored?  The comment does say read, but the difference is subtle enough
that I want to double-check.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list