From 104fd823b2216351610f0f3986cbc22b52304396 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 6 Feb 2014 22:13:42 +0900 Subject: [PATCH] use a pointer to newly allocated region to pass to xh_put --- src/symbol.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/symbol.c b/src/symbol.c index 62057ab7..816e72bc 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -21,6 +21,8 @@ pic_intern_cstr(pic_state *pic, const char *str) return e->val; } + str = pic_strdup(pic, str); + if (pic->slen >= pic->scapa) { #if DEBUG @@ -31,7 +33,7 @@ pic_intern_cstr(pic_state *pic, const char *str) pic->sym_pool = pic_realloc(pic, pic->sym_pool, sizeof(const char *) * pic->scapa); } id = pic->slen++; - pic->sym_pool[id] = pic_strdup(pic, str); + pic->sym_pool[id] = str; xh_put(pic->sym_tbl, str, id); return id; }