diff options
author | Vladimir Pantelic <vladoman@gmail.com> | 2013-01-24 14:09:48 +0000 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2013-01-25 10:47:51 +0100 |
commit | b85a5e87af4254b80913fe33591d96361f30832b (patch) | |
tree | c455a00d43d40bfb52080ab6f4ad8da3d2cdb4fb /libavutil/avstring.c | |
parent | a84fb6e06f7f13e61b5dad0224fa392ebe65e294 (diff) | |
download | ffmpeg-b85a5e87af4254b80913fe33591d96361f30832b.tar.gz |
lavu: Add av_strnstr()
This is a length limited version of strstr()
Signed-off-by: Vladimir Pantelic <vladoman@gmail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Diffstat (limited to 'libavutil/avstring.c')
-rw-r--r-- | libavutil/avstring.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libavutil/avstring.c b/libavutil/avstring.c index a16adcb3fe..625f723686 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -65,6 +65,20 @@ char *av_stristr(const char *s1, const char *s2) return NULL; } +char *av_strnstr(const char *haystack, const char *needle, size_t hay_length) +{ + size_t needle_len = strlen(needle); + if (!needle_len) + return haystack; + while (hay_length >= needle_len) { + hay_length--; + if (!memcmp(haystack, needle, needle_len)) + return haystack; + haystack++; + } + return NULL; +} + size_t av_strlcpy(char *dst, const char *src, size_t size) { size_t len = 0; |