ts_copy.c - plan9port - [fork] Plan 9 from user space
HTML git clone git://src.adamsgaard.dk/plan9port
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
ts_copy.c (359B)
---
1 #include <u.h>
2 #include <libc.h>
3 #include "libString.h"
4
5
6 /* return a String containing a copy of the passed char array */
7 extern String*
8 s_copy(char *cp)
9 {
10 String *sp;
11 int len;
12
13 len = strlen(cp)+1;
14 sp = s_newalloc(len);
15 setmalloctag(sp, getcallerpc(&cp));
16 strcpy(sp->base, cp);
17 sp->ptr = sp->base + len - 1; /* point to 0 terminator */
18 return sp;
19 }