Add libString.

This commit is contained in:
rsc 2003-12-11 18:15:57 +00:00
parent 57ccfb9e8f
commit 7f11104a57
20 changed files with 1315 additions and 0 deletions

19
src/libString/s_copy.c Normal file
View file

@ -0,0 +1,19 @@
#include <u.h>
#include <libc.h>
#include "libString.h"
/* return a String containing a copy of the passed char array */
extern String*
s_copy(char *cp)
{
String *sp;
int len;
len = strlen(cp)+1;
sp = s_newalloc(len);
setmalloctag(sp, getcallerpc(&cp));
strcpy(sp->base, cp);
sp->ptr = sp->base + len - 1; /* point to 0 terminator */
return sp;
}