mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-21 05:26:23 +00:00
registrychunks: Use strnlen if available
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
This commit is contained in:
parent
6907abdca8
commit
99901ffab4
2 changed files with 14 additions and 1 deletions
|
@ -46,7 +46,18 @@
|
|||
#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;
|
||||
|
@ -58,6 +69,7 @@ _strnlen (const gchar * str, gint maxlen)
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Macros */
|
||||
#define unpack_element(inptr, outptr, element, endptr, error_label) G_STMT_START{ \
|
||||
|
|
|
@ -230,6 +230,7 @@ check_functions = [
|
|||
'pselect',
|
||||
'getpagesize',
|
||||
'clock_gettime',
|
||||
'strnlen',
|
||||
# These are needed by libcheck
|
||||
'getline',
|
||||
'mkstemp',
|
||||
|
|
Loading…
Reference in a new issue