[FFmpeg-devel] [PATCH 1/2] avutil/avstring: add av_strnlen()

Michael Niedermayer michaelni at gmx.at
Sat Dec 21 17:18:42 CET 2013


Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavutil/avstring.h |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libavutil/avstring.h b/libavutil/avstring.h
index 882a2b5..fb8236f 100644
--- a/libavutil/avstring.h
+++ b/libavutil/avstring.h
@@ -132,6 +132,17 @@ size_t av_strlcat(char *dst, const char *src, size_t size);
 size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) av_printf_format(3, 4);
 
 /**
+ * Gets the count of continuous non zero chars starting from the begin.
+ */
+static inline size_t av_strnlen(const char *s, size_t len)
+{
+    int i;
+    for (i = 0; i<len && s[i]; i++)
+        ;
+    return i;
+}
+
+/**
  * Print arguments following specified format into a large enough auto
  * allocated buffer. It is similar to GNU asprintf().
  * @param fmt printf-compatible format string, specifying how the
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list