[bugfix] must multiply the size by sizeof(struct) when using realloc function
This commit is contained in:
parent
a315f518d2
commit
1aa35891ad
|
@ -343,8 +343,8 @@ codegen(codegen_state *state, pic_value obj, bool tailpos)
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
puts("irep realloced");
|
puts("irep realloced");
|
||||||
#endif
|
#endif
|
||||||
scope->irep = (struct pic_irep **)pic_realloc(pic, scope->irep, scope->icapa * 2);
|
|
||||||
scope->icapa *= 2;
|
scope->icapa *= 2;
|
||||||
|
scope->irep = (struct pic_irep **)pic_realloc(pic, scope->irep, sizeof(struct pic_irep *) * scope->icapa);
|
||||||
}
|
}
|
||||||
k = scope->ilen++;
|
k = scope->ilen++;
|
||||||
scope->code[scope->clen].insn = OP_LAMBDA;
|
scope->code[scope->clen].insn = OP_LAMBDA;
|
||||||
|
@ -458,8 +458,8 @@ codegen(codegen_state *state, pic_value obj, bool tailpos)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scope->plen >= scope->pcapa) {
|
if (scope->plen >= scope->pcapa) {
|
||||||
scope->pool = (pic_value *)pic_realloc(pic, scope->pool, scope->pcapa * 2);
|
|
||||||
scope->pcapa *= 2;
|
scope->pcapa *= 2;
|
||||||
|
scope->pool = (pic_value *)pic_realloc(pic, scope->pool, sizeof(pic_value) * scope->pcapa);
|
||||||
}
|
}
|
||||||
pidx = scope->plen++;
|
pidx = scope->plen++;
|
||||||
scope->pool[pidx] = pic_car(pic, pic_cdr(pic, obj));
|
scope->pool[pidx] = pic_car(pic, pic_cdr(pic, obj));
|
||||||
|
@ -695,8 +695,8 @@ codegen(codegen_state *state, pic_value obj, bool tailpos)
|
||||||
case PIC_TT_BLOB: {
|
case PIC_TT_BLOB: {
|
||||||
int pidx;
|
int pidx;
|
||||||
if (scope->plen >= scope->pcapa) {
|
if (scope->plen >= scope->pcapa) {
|
||||||
scope->pool = (pic_value *)pic_realloc(pic, scope->pool, scope->pcapa * 2);
|
|
||||||
scope->pcapa *= 2;
|
scope->pcapa *= 2;
|
||||||
|
scope->pool = (pic_value *)pic_realloc(pic, scope->pool, sizeof(pic_value) * scope->pcapa);
|
||||||
}
|
}
|
||||||
pidx = scope->plen++;
|
pidx = scope->plen++;
|
||||||
scope->pool[pidx] = obj;
|
scope->pool[pidx] = obj;
|
||||||
|
|
|
@ -74,8 +74,8 @@ pic_error_with_exception_handler(pic_state *pic)
|
||||||
puts("rescue realloced");
|
puts("rescue realloced");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pic->rescue = (struct pic_proc **)pic_realloc(pic, pic->rescue, pic->rlen * 2);
|
|
||||||
pic->rlen *= 2;
|
pic->rlen *= 2;
|
||||||
|
pic->rescue = (struct pic_proc **)pic_realloc(pic, pic->rescue, sizeof(struct pic_proc *) * pic->rlen);
|
||||||
}
|
}
|
||||||
pic->rescue[pic->ridx++] = handler;
|
pic->rescue[pic->ridx++] = handler;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue