Commit b028d914 authored by Thibault Saunier's avatar Thibault Saunier

tests:icles: Fix previous patch by implementing our memmem

Using the string version of it will fail on '\0'.
parent 7e8fe284
......@@ -31,6 +31,29 @@
#define SAMPLE_FREQ 44100
void *
_memmem (const void *haystack, size_t hlen, const void *needle, size_t nlen)
{
int needle_first;
const void *p = haystack;
size_t plen = hlen;
if (!nlen)
return NULL;
needle_first = *(unsigned char *) needle;
while (plen >= nlen && (p = memchr (p, needle_first, plen - nlen + 1))) {
if (!memcmp (p, needle, nlen))
return (void *) p;
p++;
plen = hlen - (p - haystack);
}
return NULL;
}
static GstClockTime
sample_to_nanotime (guint sample)
{
......@@ -208,10 +231,7 @@ test_seek_FORMAT_TIME_by_sample (const gchar * fn, GList * seek_positions)
buf = gst_sample_get_buffer (sample);
gst_buffer_map (buf, &map, GST_MAP_READ);
if (map.size > answer_size)
found = NULL;
else
found = g_strstr_len (answer, answer_size, (gchar *) map.data);
found = _memmem (answer, answer_size, map.data, map.size);
gst_buffer_unmap (buf, &map);
g_assert (found != NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment