mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 18:05:37 +00:00
tests:icles: Fix previous patch by implementing our memmem
Using the string version of it will fail on '\0'.
This commit is contained in:
parent
7e8fe2844b
commit
b028d91439
1 changed files with 24 additions and 4 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue