shithub: riscv

ref: 3864ccc42aa08dba37937b280f7d814a786c5b31
dir: /sys/src/libString/s_copy.c/

View raw version
#include <u.h>
#include <libc.h>
#include "String.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;
}