strdup.c: Code cleanup

This commit is contained in:
Alexander Barton 2014-03-16 22:59:03 +01:00
parent 6238196dac
commit 51396f8f1c
1 changed files with 10 additions and 9 deletions

View File

@ -19,18 +19,19 @@
#include "exp.h"
GLOBAL char *
strdup( const char *s )
strdup(const char *s)
{
char *dup;
size_t len = strlen( s );
size_t alloc = len + 1;
char *dup;
size_t len = strlen(s);
size_t alloc = len + 1;
if (len >= alloc ) return NULL;
dup = malloc( alloc );
if (dup) strlcpy(dup, s, alloc );
if (len >= alloc)
return NULL;
dup = malloc(alloc);
if (dup)
strlcpy(dup, s, alloc );
return dup;
return dup;
}
#endif