plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

s_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 }