use picrin's strdup impl if possible

This commit is contained in:
Yuichi Nishiwaki 2014-02-01 19:32:39 +09:00
parent d48ae9227a
commit 1746243b15
4 changed files with 4 additions and 4 deletions

View File

@ -30,7 +30,7 @@ pic_blob_new(pic_state *pic, char *dat, size_t len)
struct pic_blob *bv; struct pic_blob *bv;
bv = (struct pic_blob *)pic_obj_alloc(pic, sizeof(struct pic_blob), PIC_TT_BLOB); bv = (struct pic_blob *)pic_obj_alloc(pic, sizeof(struct pic_blob), PIC_TT_BLOB);
bv->data = strndup(dat, len); bv->data = pic_strndup(pic, dat, len);
bv->len = len; bv->len = len;
return bv; return bv;
} }

View File

@ -131,7 +131,7 @@ pic_error_error(pic_state *pic)
e = (struct pic_error *)pic_obj_alloc(pic, sizeof(struct pic_error), PIC_TT_ERROR); e = (struct pic_error *)pic_obj_alloc(pic, sizeof(struct pic_error), PIC_TT_ERROR);
e->type = PIC_ERROR_OTHER; e->type = PIC_ERROR_OTHER;
e->msg = strdup(str); e->msg = pic_strdup(pic, str);
e->irrs = pic_list_from_array(pic, argc, argv); e->irrs = pic_list_from_array(pic, argc, argv);
pic_raise(pic, pic_obj_value(e)); pic_raise(pic, pic_obj_value(e));

View File

@ -13,7 +13,7 @@ pic_str_new(pic_state *pic, const char *cstr, size_t len)
str = (struct pic_string *)pic_obj_alloc(pic, sizeof(struct pic_string), PIC_TT_STRING); str = (struct pic_string *)pic_obj_alloc(pic, sizeof(struct pic_string), PIC_TT_STRING);
str->len = len; str->len = len;
str->str = strdup(cstr); str->str = pic_strdup(pic, cstr);
return str; return str;
} }

View File

@ -31,7 +31,7 @@ pic_intern_cstr(pic_state *pic, const char *str)
pic->sym_pool = pic_realloc(pic, pic->sym_pool, sizeof(const char *) * pic->scapa); pic->sym_pool = pic_realloc(pic, pic->sym_pool, sizeof(const char *) * pic->scapa);
} }
id = pic->slen++; id = pic->slen++;
pic->sym_pool[id] = strdup(str); pic->sym_pool[id] = pic_strdup(pic, str);
xh_put(pic->sym_tbl, str, id); xh_put(pic->sym_tbl, str, id);
return id; return id;
} }