/ Published in: C
Expand |
Embed | Plain Text
#include <stdlib.h> #include <string.h> #include <assert.h> /* * public domain strdup() */ char* strdup( char const* s) { size_t siz = 0; char* result = NULL; assert( s); siz = strlen( s) + 1; result = (char*) malloc( siz); if (result) { memcpy( result, s, siz); } return result; }
You need to login to post a comment.
