Re: FreeVal in motoc_array_new
David Hakim <dhakim-Gkm/TONP9n1Wk0Htik3J/[email protected]> Sat, 10 May 2003 19:00:39 -0400
| Newsgroups | gmane.comp.lang.moto.devel |
|---|---|
| Message-ID | <[email protected]> |
Does moto_freeVal free codeval.value when in compiler mode ? I'm
worried that it might. If this is the case then codeval.value may need
to be moto_strdup'ed for that while loop to work reliably.
-Dave
On Saturday, May 10, 2003, at 08:13 PM, Stefano Corsi wrote:
> Dave,
>
> look at this piece of code from motoc_array_new:
>
> while(stack_size(frame->opstack) > stacksize){
> MotoVal* indexMotoVal = opstack_pop(env);
>
> arrayIndexExpressions[i] = indexMotoVal->codeval.value;
> i--;
> moto_freeVal(env,indexMotoVal);
> }
>
> the val is freed after it has been assigned to
> arrayIndexExpressions[i]...
>
> If in motoc_Assign I say:
>
> motoc(uc_operand(p, 2));
> v2 = opstack_pop(env);
>
> motoc(uc_operand(p, 0));
> v1 = opstack_pop(env);
>
> tests/class_succ and its String[] initialization works anyway...
>
> If I instead I say:
>
> motoc(uc_operand(p, 0));
> v1 = opstack_pop(env);
>
> motoc(uc_operand(p, 2));
> v2 = opstack_pop(env);
>
> arrayIndexExpressions[i] ends up being null, as expected... and
> initialization
> doesn't work...
>
> Do you understand what happens?
>
> Stefano
>