refactor pic_gensym

This commit is contained in:
Yuichi Nishiwaki 2014-03-26 14:49:48 +09:00
parent 03bf4cb5eb
commit a1101296aa
1 changed files with 4 additions and 4 deletions

View File

@ -40,13 +40,13 @@ pic_intern_cstr(pic_state *pic, const char *str)
pic_sym
pic_gensym(pic_state *pic, pic_sym base)
{
int id;
int uid = pic->uniq_sym_cnt++, len;
char *str;
pic_sym uniq;
id = ++pic->uniq_sym_cnt;
str = (char *)pic_alloc(pic, strlen(pic_symbol_name(pic, base)) + (int)log10(id) + 3);
sprintf(str, "%s@%d", pic_symbol_name(pic, base), id);
len = snprintf(NULL, 0, "%s@%d", pic_symbol_name(pic, base), uid);
str = pic_alloc(pic, len + 1);
sprintf(str, "%s@%d", pic_symbol_name(pic, base), uid);
/* don't put the symbol to pic->syms to keep it uninterned */
uniq = pic->sym_cnt++;