add strdup for debugging.
This commit is contained in:
parent
ca9b36624f
commit
f437e56d1d
2 changed files with 18 additions and 0 deletions
|
|
@ -137,6 +137,7 @@ LIB9OFILES=\
|
||||||
seek.$O\
|
seek.$O\
|
||||||
sendfd.$O\
|
sendfd.$O\
|
||||||
sleep.$O\
|
sleep.$O\
|
||||||
|
strdup.$O\
|
||||||
strecpy.$O\
|
strecpy.$O\
|
||||||
sysfatal.$O\
|
sysfatal.$O\
|
||||||
sysname.$O\
|
sysname.$O\
|
||||||
|
|
|
||||||
17
src/lib9/strdup.c
Normal file
17
src/lib9/strdup.c
Normal file
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue