Bill Allombert on Wed, 11 May 2011 09:59:37 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: allocatemoremem() backwards compatibility |
On Tue, May 10, 2011 at 08:52:03PM -0700, Lorenz Minder wrote: > Hi Bill, > > Bill Allombert wrote: > > On Tue, May 10, 2011 at 09:57:10AM +0200, Jeroen Demeyer wrote: > > > Hello, > > > > > > Does the libpari function allocatemem() behave the same as the old > > > function allocatemoremem()? > > > > Not really. allocatemem() end with cb_pari_err_recover(), while > > allocatemoremem() did not. > > That's great news, and I will update my code if I get around to. > (Unfortunately I have rarely time for that nowadays.) > > > > I think you should add a declaration in pariold.h for allocatemoremem(). > > > Some external programs use that function. > > > > allocatemoremem() was removed because it was not safe to use in most case. > > Also the documentation stated that it returned void, while in fact it was returning > > a long. > > > > How did you use that function ? > > I use it in a snippet like this: > > stack_clean(); > allocatemoremem(sz); > stack_init(); > > Here, stack_clean() clones every live object residing on the stack, and > stack_init() does essentially an "avma = top;" (in addition to > implementing a workaround for a pari < 2.4.3 bug). Is this a safe use > (if we ignore the possibility that allocatemoremem() might not actually > manage to allocate memory)? I suppose you know what you are doing, so it is probably safe in your case. However generally, it is only safe if there are no pending reference to the old stack anywhere, which is very hard to ensure unless avma==top. Cheers, Bill.