static my_strndup() => extern nfstrndup()
This commit is contained in:
parent
4d638c3cf2
commit
e00d0f1ac3
|
@ -112,6 +112,7 @@ time_t timegm( struct tm *tm );
|
|||
void *nfmalloc( size_t sz );
|
||||
void *nfcalloc( size_t sz );
|
||||
void *nfrealloc( void *mem, size_t sz );
|
||||
char *nfstrndup( const char *str, size_t nchars );
|
||||
char *nfstrdup( const char *str );
|
||||
int nfvasprintf( char **str, const char *fmt, va_list va );
|
||||
int ATTR_PRINTFLIKE(2, 3) nfasprintf( char **str, const char *fmt, ... );
|
||||
|
|
26
src/util.c
26
src/util.c
|
@ -354,14 +354,19 @@ nfrealloc( void *mem, size_t sz )
|
|||
return ret;
|
||||
}
|
||||
|
||||
char *
|
||||
nfstrndup( const char *str, size_t nchars )
|
||||
{
|
||||
char *ret = nfmalloc( nchars + 1 );
|
||||
memcpy( ret, str, nchars );
|
||||
ret[nchars] = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *
|
||||
nfstrdup( const char *str )
|
||||
{
|
||||
char *ret;
|
||||
|
||||
if (!(ret = strdup( str )))
|
||||
oom();
|
||||
return ret;
|
||||
return nfstrndup( str, strlen( str ) );
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -405,15 +410,6 @@ cur_user( void )
|
|||
}
|
||||
*/
|
||||
|
||||
static char *
|
||||
my_strndup( const char *s, size_t nchars )
|
||||
{
|
||||
char *r = nfmalloc( nchars + 1 );
|
||||
memcpy( r, s, nchars );
|
||||
r[nchars] = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
char *
|
||||
expand_strdup( const char *s )
|
||||
{
|
||||
|
@ -431,7 +427,7 @@ expand_strdup( const char *s )
|
|||
q = Home;
|
||||
} else {
|
||||
if ((p = strchr( s, '/' ))) {
|
||||
r = my_strndup( s, (int)(p - s) );
|
||||
r = nfstrndup( s, (int)(p - s) );
|
||||
pw = getpwnam( r );
|
||||
free( r );
|
||||
} else
|
||||
|
|
Loading…
Reference in New Issue
Block a user