Can I see how much of my stack has been filled up?
I suppose that if I could see the value of avma, that'd help.
Moreover, if I do an operation on a variable and store the return value in the same variable, does it replace the initial value of the variable?
Does moving the stack pointer up overwrite everything below that point (in case I further fill up the stack), even the assigned variables?

- 187
- 7
1 Answers
Can I see how much of my stack has been filled up? I suppose that if I could see the value of avma, that'd help.
Just print avma
then: printf("avma = %lu", avma);
or %lX
if you prefer hexadecimal values.
Moreover, if I do an operation on a variable and store the return value in the same variable, does it replace the initial value of the variable?
The question is too vague. I'm assuming you mean something like
GEN x;
x = fun1();
x = fun2();
Then x
points to the new data created by fun2
on the pari stack (GEN
is a pointer type) but the old data is still there on the stack, right where fun1
created it. This is no different from what you'd get if the functions above returned malloc
'ed memory: the above code would leak memory. That's the very reason you need GC in libpari programming.
Does moving the stack pointer up overwrite everything below that point (in case I further fill up the stack), even the assigned variables?
Yes. There's nothing special about "assigned variables", they are just pointers to some place on the pari stack, indicating where the object is written (actually, the object root).
There is a way to create GEN
objects outside of the pari stack (so-called clones) using gclone
and those would be unaffected.

- 861
- 5
- 14