Skip to content

Commit

Permalink
libfeos: tidy up strdup.c
Browse files Browse the repository at this point in the history
  • Loading branch information
fincs committed Oct 14, 2012
1 parent a9e51b5 commit 58a077a
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions sdk/source/strdup.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
#include <stdlib.h>
#include <string.h>

char* strdup(const char* str) {
int size;
char *rc;
char* strdup(const char* str)
{
if (!str) return NULL;

if(str == NULL)
return NULL;
int size = strlen(str) + 1;
char* newstr = (char*) malloc(size);
if (!newstr) return NULL;

size = strlen(str)+1;

rc = malloc(size);
if(rc == NULL)
return NULL;

memcpy(rc, str, size);
return rc;
memcpy(newstr, str, size);
return newstr;
}

0 comments on commit 58a077a

Please sign in to comment.