mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-13 10:30:05 +01:00
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>
This commit is contained in:
committed by
Luca Barbato
parent
a84fb6e06f
commit
b85a5e87af
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user