From f437e56d1d5c8180ee2f93273f78393426efd5f9 Mon Sep 17 00:00:00 2001 From: rsc Date: Wed, 9 Jun 2004 14:15:47 +0000 Subject: [PATCH] add strdup for debugging. --- src/lib9/mkfile | 1 + src/lib9/strdup.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/lib9/strdup.c 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 +#include + +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; +} +