Changeset 287081caeb571486a0381ee9964198855706a208

Show
Ignore:
Timestamp:
24/05/08 11:24:47 (5 months ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1211621087 +0300
git-parent:

[71c7fb199ac0cadd55f686d8b8dcfbfd82353215]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1211620526 +0300
Message:

Inline strnlen() and use it

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_common.h

    r71c7fb1 r287081c  
    724724VLC_EXPORT( size_t, vlc_strlcpy, ( char *, const char *, size_t ) ); 
    725725VLC_EXPORT( int64_t, vlc_strtoll, ( const char *nptr, char **endptr, int base ) ); 
    726 VLC_EXPORT( size_t, vlc_strnlen, ( const char *, size_t ) ); 
    727726 
    728727struct dirent; 
  • include/vlc_fixups.h

    rcb63940 r287081c  
    4848#endif 
    4949 
     50#ifndef HAVE_STRNLEN 
     51static inline size_t strnlen (const char *str, size_t max) 
     52{ 
     53    const char *end = memchr (str, 0, max); 
     54    return end ? (size_t)(end - str) : max; 
     55} 
     56#endif 
     57 
    5058#ifndef HAVE_STRNDUP 
    5159static inline char *strndup (const char *str, size_t max) 
    5260{ 
    53     const char *end = memchr (str, '\0', max); 
    54     size_t len = end ? (size_t)(end - str) : max; 
     61    size_t len = strnlen (str, max); 
    5562    char *res = malloc (len + 1); 
    5663    if (res) 
     
    6168    return res; 
    6269} 
    63 #endif 
    64  
    65 #ifndef HAVE_STRNLEN 
    66 # define strnlen vlc_strnlen 
    6770#endif 
    6871 
  • src/extras/libc.c

    rcb63940 r287081c  
    7676 
    7777/***************************************************************************** 
    78  * strnlen: 
    79  *****************************************************************************/ 
    80 #if !defined( HAVE_STRNLEN ) 
    81 size_t vlc_strnlen( const char *psz, size_t n ) 
    82 { 
    83     const char *psz_end = memchr( psz, 0, n ); 
    84     return psz_end ? (size_t)( psz_end - psz ) : n; 
    85 } 
    86 #endif 
    87  
    88 /***************************************************************************** 
    8978 * strcasecmp: compare two strings ignoring case 
    9079 *****************************************************************************/ 
  • src/libvlccore.sym

    rcb63940 r287081c  
    443443vlc_strlcpy 
    444444vlc_strncasecmp 
    445 vlc_strnlen 
    446445vlc_strtoll 
    447446vlc_submodule_create