Karim BELABAS on Tue, 12 Feb 2002 13:07:59 +0100 (MET) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: brutcopy and gcopy_av |
On Thu, 7 Feb 2002, Ilya Zakharevich wrote: > On Thu, Feb 07, 2002 at 01:14:33PM +0100, Karim BELABAS wrote: > > What exactly do you need it for, that gclone() does not provide ? [this will > > help me decide the "final" form of the public interface...] > > Does gclone() move things from the heap to the stack? Then probably > gcopy_av() is not needed indeed. In PARI technobabble, it's exactly the other way round: stack = huge chunk of memory [parisize] where avma, bot, top & friends live. Except when specifically mentionned in the docs (e.g gmodulo), PARI functions return results which live here. gerepile* functions operate here. "stack overflow" occurs here. heap = linked list of "blocs", where "permanent" objects live: cached values for pi, Euler constant, Bernoulli numbers, log(2), GP history (%1, etc), values of GP variables. "heap overflow" occurs as "no enough memory" messages [failed malloc] gclone(x) = create a (complete) copy of x, allocated (as a single "bloc") in the heap gcopy(x) = create a copy of x, allocated in the stack. Some subobjects of x not living in the heap may only copied as pointers (modulus of t_INTMOD, t_POLMOD object) forcecopy(x) = as above, but complete copy guaranteed gunclone(x) = destroy a clone [assumes x = gclone(y)], freeing the corresponding "bloc". Former brutcopy/current gcopy_av: copy an object to a preallocated buffer ( whose size should have been determined by taille() ). There's a silly technical difference between the two [ linked to the fact that a bloc is not a decent struct, but is operated upon by assembler-like macros, x[-1], x[-2], etc. ], but I'm trying to make the reason for it disappear, so I won't bother you with that, unless you ask for it :-) Hope this helps, Karim. -- Karim Belabas Tel: (+33) (0)1 69 15 57 48 Dép. de Mathematiques, Bat. 425 Fax: (+33) (0)1 69 15 60 19 Université Paris-Sud Email: Karim.Belabas@math.u-psud.fr F-91405 Orsay (France) http://www.math.u-psud.fr/~belabas -- PARI/GP Home Page: http://www.parigp-home.de/