diff options
Diffstat (limited to 'src/lib9')
-rw-r--r-- | src/lib9/mkfile | 1 | ||||
-rw-r--r-- | src/lib9/strdup.c | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/lib9/mkfile b/src/lib9/mkfile index bea11659..7ade5b63 100644 --- a/src/lib9/mkfile +++ b/src/lib9/mkfile @@ -137,6 +137,7 @@ LIB9OFILES=\ seek.$O\ sendfd.$O\ sleep.$O\ + strdup.$O\ strecpy.$O\ sysfatal.$O\ sysname.$O\ diff --git a/src/lib9/strdup.c b/src/lib9/strdup.c new file mode 100644 index 00000000..5ca31866 --- /dev/null +++ b/src/lib9/strdup.c @@ -0,0 +1,17 @@ +#include <u.h> +#include <libc.h> + +char* +strdup(char *s) +{ + char *t; + int l; + + l = strlen(s); + t = malloc(l+1); + if(t == nil) + return nil; + memmove(t, s, l+1); + return t; +} + |