2013-10-10 04:22:25 -04:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "picrin.h"
|
|
|
|
|
|
|
|
pic_value
|
2013-10-10 04:54:35 -04:00
|
|
|
pic_intern_cstr(pic_state *pic, const char *name)
|
2013-10-10 04:22:25 -04:00
|
|
|
{
|
|
|
|
struct pic_symbol *sym;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
sym = (struct pic_symbol*)pic_gc_alloc(pic, sizeof(struct pic_symbol), PIC_TT_SYMBOL);
|
|
|
|
|
|
|
|
/* clone name string */
|
|
|
|
len = strlen(name);
|
|
|
|
sym->name = (char *)pic_alloc(pic, len + 1);
|
|
|
|
strncpy(sym->name, name, len + 1);
|
|
|
|
|
|
|
|
return pic_obj_value(sym);
|
|
|
|
}
|