remove pic_irep.ilen

This commit is contained in:
Yuichi Nishiwaki 2016-02-05 20:47:08 +09:00
parent 5e58847721
commit e96465f724
3 changed files with 6 additions and 6 deletions

View File

@ -701,8 +701,8 @@ codegen_context_destroy(pic_state *pic, codegen_context *cxt)
irep->localc = (int)cxt->locals->len; irep->localc = (int)cxt->locals->len;
irep->capturec = (int)cxt->captures->len; irep->capturec = (int)cxt->captures->len;
irep->code = pic_realloc(pic, cxt->code, sizeof(pic_code) * cxt->clen); irep->code = pic_realloc(pic, cxt->code, sizeof(pic_code) * cxt->clen);
irep->irep = pic_realloc(pic, cxt->irep, sizeof(struct pic_irep *) * cxt->ilen); irep->irep = pic_realloc(pic, cxt->irep, sizeof(struct pic_irep *) * (cxt->ilen + 1));
irep->ilen = cxt->ilen; irep->irep[cxt->ilen] = NULL;
irep->pool = pic_realloc(pic, cxt->pool, sizeof(pic_value) * cxt->plen); irep->pool = pic_realloc(pic, cxt->pool, sizeof(pic_value) * cxt->plen);
irep->plen = cxt->plen; irep->plen = cxt->plen;

View File

@ -31,7 +31,6 @@ struct pic_irep {
int argc, localc, capturec; int argc, localc, capturec;
bool varg; bool varg;
struct pic_irep **irep; struct pic_irep **irep;
size_t ilen;
pic_value *pool; pic_value *pool;
size_t plen; size_t plen;
}; };

View File

@ -13,7 +13,7 @@ pic_irep_incref(pic_state PIC_UNUSED(*pic), struct pic_irep *irep)
void void
pic_irep_decref(pic_state *pic, struct pic_irep *irep) pic_irep_decref(pic_state *pic, struct pic_irep *irep)
{ {
size_t i; struct pic_irep **i;
if (--irep->refc == 0) { if (--irep->refc == 0) {
pic_free(pic, irep->code); pic_free(pic, irep->code);
@ -23,8 +23,9 @@ pic_irep_decref(pic_state *pic, struct pic_irep *irep)
irep->list.prev->next = irep->list.next; irep->list.prev->next = irep->list.next;
irep->list.next->prev = irep->list.prev; irep->list.next->prev = irep->list.prev;
for (i = 0; i < irep->ilen; ++i) { i = irep->irep;
pic_irep_decref(pic, irep->irep[i]); while (*i) {
pic_irep_decref(pic, *i++);
} }
pic_free(pic, irep->irep); pic_free(pic, irep->irep);
pic_free(pic, irep); pic_free(pic, irep);