1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/* ** Portable, public domain strdup() by Bob Stout */ #include <stdlib.h> #include <string.h> char *strdup(const char *string) { char *new; if (NULL != (new = malloc(strlen(string) + 1))) strcpy(new, string); return new; }