[FFmpeg-devel] [RFC] SDP Generation

Luca Abeni lucabe72
Wed Jul 18 11:53:57 CEST 2007


Hi,

Michael Niedermayer wrote:
[...]
>> I think this strlcatf() function can be useful for others too, and not 
>> only for the SDP generator. Should I submit a patch adding av_strlcatf() 
>> to libavutil/string.c?
> 
> yes

Ok, here it is... I hope I got it right.
The attached patch implements the semantic I proposed (the returned 
value is equal to the total length of the resulting string).
Maybe for consistency with av_strlcat() it could be more interesting to 
return the length of the string that would have been generated if enough 
space had been available. In such case, the implementation would have been

size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...)
{
     int len = strlen(dst);
     va_list vl;
     int res;

     va_start(vl, fmt);
     res = vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl);
     va_end(vl);

     return len + res;
}

Let me know which variant is preferred, and if it is ok for commit.


				Thanks,
					Luca
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: strlcatf.diff
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070718/31152667/attachment.txt>



More information about the ffmpeg-devel mailing list