Mercurial > libavutil.hg
diff string.c @ 369:2cd0add8ac0c libavutil
Implement av_strlcatf(): a strlcat which adds a printf style formatted string
author | lucabe |
---|---|
date | Thu, 19 Jul 2007 06:36:02 +0000 |
parents | 92b31fec32b0 |
children |
line wrap: on
line diff
--- a/string.c Wed Jul 18 12:22:07 2007 +0000 +++ b/string.c Thu Jul 19 06:36:02 2007 +0000 @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include <stdarg.h> +#include <stdio.h> #include <string.h> #include <ctype.h> #include "avstring.h" @@ -62,3 +64,15 @@ return len + strlen(src); return len + av_strlcpy(dst + len, src, size - len); } + +size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) +{ + int len = strlen(dst); + va_list vl; + + va_start(vl, fmt); + len += vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl); + va_end(vl); + + return len; +}