Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include "String.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
}