don't chain ireps whose npool is zero
This commit is contained in:
parent
52b5e6e521
commit
5af735d796
|
@ -635,6 +635,7 @@ codegen_context_destroy(pic_state *pic, codegen_context *cxt)
|
||||||
|
|
||||||
/* create irep */
|
/* create irep */
|
||||||
irep = pic_malloc(pic, sizeof(struct irep));
|
irep = pic_malloc(pic, sizeof(struct irep));
|
||||||
|
irep->list.next = irep->list.prev = 0;
|
||||||
irep->refc = 1;
|
irep->refc = 1;
|
||||||
irep->varg = pic_sym_p(pic, cxt->rest);
|
irep->varg = pic_sym_p(pic, cxt->rest);
|
||||||
irep->argc = pic_vec_len(pic, cxt->args) + 1;
|
irep->argc = pic_vec_len(pic, cxt->args) + 1;
|
||||||
|
@ -651,10 +652,12 @@ codegen_context_destroy(pic_state *pic, codegen_context *cxt)
|
||||||
irep->nnums = cxt->flen;
|
irep->nnums = cxt->flen;
|
||||||
irep->npool = cxt->plen;
|
irep->npool = cxt->plen;
|
||||||
|
|
||||||
irep->list.next = pic->ireps.next;
|
if (irep->npool > 0) {
|
||||||
irep->list.prev = &pic->ireps;
|
irep->list.next = pic->ireps.next;
|
||||||
irep->list.next->prev = &irep->list;
|
irep->list.prev = &pic->ireps;
|
||||||
irep->list.prev->next = &irep->list;
|
irep->list.next->prev = &irep->list;
|
||||||
|
irep->list.prev->next = &irep->list;
|
||||||
|
}
|
||||||
|
|
||||||
return irep;
|
return irep;
|
||||||
}
|
}
|
||||||
|
|
|
@ -934,8 +934,10 @@ pic_irep_decref(pic_state *pic, struct irep *irep)
|
||||||
pic_free(pic, irep->pool);
|
pic_free(pic, irep->pool);
|
||||||
|
|
||||||
/* unchain before decref children ireps */
|
/* unchain before decref children ireps */
|
||||||
irep->list.prev->next = irep->list.next;
|
if (irep->list.prev) { /* && irep->list.next */
|
||||||
irep->list.next->prev = irep->list.prev;
|
irep->list.prev->next = irep->list.next;
|
||||||
|
irep->list.next->prev = irep->list.prev;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < irep->nirep; ++i) {
|
for (i = 0; i < irep->nirep; ++i) {
|
||||||
pic_irep_decref(pic, irep->irep[i]);
|
pic_irep_decref(pic, irep->irep[i]);
|
||||||
|
|
Loading…
Reference in New Issue