[vlc-devel] commit: Inline strnlen() and use it ( Rémi Denis-Courmont )
git version control
git at videolan.org
Sat May 24 11:23:19 CEST 2008
vlc | branch: master | Rémi Denis-Courmont <rem at videolan.org> | Sat May 24 12:15:26 2008 +0300| [287081caeb571486a0381ee9964198855706a208]
Inline strnlen() and use it
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=287081caeb571486a0381ee9964198855706a208
---
include/vlc_common.h | 1 -
include/vlc_fixups.h | 15 +++++++++------
src/extras/libc.c | 11 -----------
src/libvlccore.sym | 1 -
4 files changed, 9 insertions(+), 19 deletions(-)
diff --git a/include/vlc_common.h b/include/vlc_common.h
index b4d777a..99166d4 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -723,7 +723,6 @@ VLC_EXPORT( int, vlc_vasprintf, (char **, const char *, va_list ) );
VLC_EXPORT( int, vlc_asprintf, (char **, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
VLC_EXPORT( size_t, vlc_strlcpy, ( char *, const char *, size_t ) );
VLC_EXPORT( int64_t, vlc_strtoll, ( const char *nptr, char **endptr, int base ) );
-VLC_EXPORT( size_t, vlc_strnlen, ( const char *, size_t ) );
struct dirent;
VLC_EXPORT( int, vlc_scandir, ( const char *name, struct dirent ***namelist, int (*filter) ( const struct dirent * ), int (*compar) ( const struct dirent **, const struct dirent ** ) ) );
diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
index 3f185ab..cd7dc82 100644
--- a/include/vlc_fixups.h
+++ b/include/vlc_fixups.h
@@ -47,11 +47,18 @@ static inline char *strdup (const char *str)
# define asprintf vlc_asprintf
#endif
+#ifndef HAVE_STRNLEN
+static inline size_t strnlen (const char *str, size_t max)
+{
+ const char *end = memchr (str, 0, max);
+ return end ? (size_t)(end - str) : max;
+}
+#endif
+
#ifndef HAVE_STRNDUP
static inline char *strndup (const char *str, size_t max)
{
- const char *end = memchr (str, '\0', max);
- size_t len = end ? (size_t)(end - str) : max;
+ size_t len = strnlen (str, max);
char *res = malloc (len + 1);
if (res)
{
@@ -62,10 +69,6 @@ static inline char *strndup (const char *str, size_t max)
}
#endif
-#ifndef HAVE_STRNLEN
-# define strnlen vlc_strnlen
-#endif
-
#ifndef HAVE_STRLCPY
# define strlcpy vlc_strlcpy
#endif
diff --git a/src/extras/libc.c b/src/extras/libc.c
index 3e537ad..0c10039 100644
--- a/src/extras/libc.c
+++ b/src/extras/libc.c
@@ -75,17 +75,6 @@
#endif
/*****************************************************************************
- * strnlen:
- *****************************************************************************/
-#if !defined( HAVE_STRNLEN )
-size_t vlc_strnlen( const char *psz, size_t n )
-{
- const char *psz_end = memchr( psz, 0, n );
- return psz_end ? (size_t)( psz_end - psz ) : n;
-}
-#endif
-
-/*****************************************************************************
* strcasecmp: compare two strings ignoring case
*****************************************************************************/
#if !defined( HAVE_STRCASECMP ) && !defined( HAVE_STRICMP )
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index bad95ee..24392c1 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -442,7 +442,6 @@ vlc_strcasecmp
vlc_strcasestr
vlc_strlcpy
vlc_strncasecmp
-vlc_strnlen
vlc_strtoll
vlc_submodule_create
__vlc_thread_create
More information about the vlc-devel
mailing list