strdup.c: Code cleanup
This commit is contained in:
parent
6238196dac
commit
51396f8f1c
|
@ -19,18 +19,19 @@
|
||||||
#include "exp.h"
|
#include "exp.h"
|
||||||
|
|
||||||
GLOBAL char *
|
GLOBAL char *
|
||||||
strdup( const char *s )
|
strdup(const char *s)
|
||||||
{
|
{
|
||||||
char *dup;
|
char *dup;
|
||||||
size_t len = strlen( s );
|
size_t len = strlen(s);
|
||||||
size_t alloc = len + 1;
|
size_t alloc = len + 1;
|
||||||
|
|
||||||
if (len >= alloc ) return NULL;
|
if (len >= alloc)
|
||||||
dup = malloc( alloc );
|
return NULL;
|
||||||
if (dup) strlcpy(dup, s, alloc );
|
dup = malloc(alloc);
|
||||||
|
if (dup)
|
||||||
|
strlcpy(dup, s, alloc );
|
||||||
|
|
||||||
return dup;
|
return dup;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue