xref: /plan9/sys/src/libc/port/strdup.c (revision 9b7bf7df4595c26f1e9b67beb0c6e44c9876fb05)
1 #include <u.h>
2 #include <libc.h>
3 
4 char*
strdup(char * s)5 strdup(char *s)
6 {
7 	char *ns;
8 
9 	ns = malloc(strlen(s) + 1);
10 	if(ns == 0)
11 		return 0;
12 	setmalloctag(ns, getcallerpc(&s));
13 
14 	return strcpy(ns, s);
15 }
16