refactor pic_gensym
This commit is contained in:
parent
03bf4cb5eb
commit
a1101296aa
|
@ -40,13 +40,13 @@ pic_intern_cstr(pic_state *pic, const char *str)
|
||||||
pic_sym
|
pic_sym
|
||||||
pic_gensym(pic_state *pic, pic_sym base)
|
pic_gensym(pic_state *pic, pic_sym base)
|
||||||
{
|
{
|
||||||
int id;
|
int uid = pic->uniq_sym_cnt++, len;
|
||||||
char *str;
|
char *str;
|
||||||
pic_sym uniq;
|
pic_sym uniq;
|
||||||
|
|
||||||
id = ++pic->uniq_sym_cnt;
|
len = snprintf(NULL, 0, "%s@%d", pic_symbol_name(pic, base), uid);
|
||||||
str = (char *)pic_alloc(pic, strlen(pic_symbol_name(pic, base)) + (int)log10(id) + 3);
|
str = pic_alloc(pic, len + 1);
|
||||||
sprintf(str, "%s@%d", pic_symbol_name(pic, base), id);
|
sprintf(str, "%s@%d", pic_symbol_name(pic, base), uid);
|
||||||
|
|
||||||
/* don't put the symbol to pic->syms to keep it uninterned */
|
/* don't put the symbol to pic->syms to keep it uninterned */
|
||||||
uniq = pic->sym_cnt++;
|
uniq = pic->sym_cnt++;
|
||||||
|
|
Loading…
Reference in New Issue