When this `_strnlen` internal method was added, strnlen (in glibc)
was not available yet (appeared in 2.10 it was released that same
year).
If available, use the much more optimized strnlen
#define GST_CAT_DEFAULT GST_CAT_REGISTRY
/* count string length, but return -1 if we hit the eof */
-static gint
+#ifdef HAVE_STRNLEN
+static inline gint
+_strnlen (const gchar * str, gint maxlen)
+{
+ gint len = strnlen (str, maxlen);
+
+ if (G_UNLIKELY (len == maxlen))
+ return -1;
+ return len;
+}
+#else
+static inline gint
_strnlen (const gchar * str, gint maxlen)
{
gint len = 0;
}
return -1;
}
+#endif
/* Macros */
#define unpack_element(inptr, outptr, element, endptr, error_label) G_STMT_START{ \
'pselect',
'getpagesize',
'clock_gettime',
+ 'strnlen',
# These are needed by libcheck
'getline',
'mkstemp',