[FFmpeg-devel] [PATCH] avio: add avio_get_str as a replacement for get_strz

Michael Niedermayer michaelni
Wed Mar 2 14:07:46 CET 2011


On Wed, Mar 02, 2011 at 12:46:45PM +0000, M?ns Rullg?rd wrote:
> Michael Niedermayer <michaelni at gmx.at> writes:
> 
> > On Tue, Mar 01, 2011 at 06:33:56PM +0100, Anton Khirnov wrote:
> >> It's more flexible and compatible with avio_get_str16.
> >> ---
> >>  libavformat/avio.h    |   15 ++++++++++++++-
> >>  libavformat/aviobuf.c |   29 +++++++++++++++++++----------
> >>  libavformat/cafdec.c  |    4 ++--
> >>  libavformat/ffmdec.c  |    3 ++-
> >>  libavformat/mov.c     |    2 +-
> >>  5 files changed, 38 insertions(+), 15 deletions(-)
> >> 
> >> diff --git a/libavformat/avio.h b/libavformat/avio.h
> >> index cc46ad7..7e0dca0 100644
> >> --- a/libavformat/avio.h
> >> +++ b/libavformat/avio.h
> >> @@ -526,6 +526,14 @@ unsigned int avio_rl32(AVIOContext *s);
> >>  uint64_t     avio_rl64(AVIOContext *s);
> >>  
> >>  /**
> >> + * Read a UTF-8 string from pb. The reading will terminate when either
> >> + * a NULL character was encountered or maxlen bytes have been read.
> >
> > This doesnt match the code, it does not mention zero termination behavior
> > for the truncated case
> >
> >> + *
> >> + * @return number of bytes read (is always <= maxlen).
> >> + */
> >
> > This is not very convenient
> > We rarely care about the length, but we often care about having truncated data
> >
> > @return buffer size - bytes read, this is negative if the string was truncated
> > and easy to find the number of bytes read from it in the rare case where we
> > might want it
> 
> How will you report an error with the return value defined like that?

If you would read the code you would see that there is no error case in there
except truncation.
And if there was an error case the patch that was suggested by anton could
not return it either as the return value is defined like this:
@return number of bytes read (is always <= maxlen).

and not if no error ... else ...

so please stop trolling
thanks


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 1
"Used only once"    - "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110302/b4df3b1d/attachment.pgp>



More information about the ffmpeg-devel mailing list