Re: mpz_prevprime

2020-03-09 Thread Seth Troisi
On Mon, Mar 9, 2020 at 5:03 AM Marco Bodrato wrote: > Ciao, > > Il 2020-03-09 11:59 Seth Troisi ha scritto: > > On Mon, Mar 9, 2020 at 2:05 AM Marco Bodrato > > wrote: > > > >> Ciao, > >> > >> Il 2020-03-09 02:56 Seth Troisi ha scritto: > > > It's highly possible I misunderstand how these macros

Re: [PATCH] mini-gmp: pass correct old_size to custom reallocate function

2020-03-09 Thread minux
Hello, On Mon, Mar 9, 2020 at 8:43 AM Marco Bodrato wrote: > Il 2020-03-09 13:04 minux ha scritto: > > I added a check for out-of-range base to the beginning of mpq_get_str > > I'd prefer to let checking ranges outside of the mpq code. > If res==NULL for whatever reason, goto ret is incorrect any

Re: [PATCH] mini-gmp: pass correct old_size to custom reallocate function

2020-03-09 Thread Marco Bodrato
Ciao, Il Lun, 9 Marzo 2020 12:30 pm, Niels Möller ha scritto: > Marco Bodrato writes: >> For the style, I do not know which one is better: >> "if(c){v=val}else{v=0};" or "v=0;if(c){v=val};" > I don't have a very strong opinion on this point, but when it's easy to > do, I prefer to assign once on

Re: [PATCH] mini-gmp: pass correct old_size to custom reallocate function

2020-03-09 Thread Marco Bodrato
Ciao, Il Lun, 9 Marzo 2020 2:08 pm, Niels Möller ha scritto: > Marco Bodrato writes: > >> -gmp_free_func (rden, 0); >> +gmp_free_func (rden, lden * sizeof (char)); > > sizeof (char) == 1 by definition, so no need to multiply with it. Of course you are right! Ĝis, m

Re: [PATCH] mini-gmp: pass correct old_size to custom reallocate function

2020-03-09 Thread Niels Möller
Marco Bodrato writes: > -gmp_free_func (rden, 0); > +gmp_free_func (rden, lden * sizeof (char)); sizeof (char) == 1 by definition, so no need to multiply with it. Regards, /Niels -- Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677. Internet email is subject to wholesale

Re: [PATCH] mini-gmp: pass correct old_size to custom reallocate function

2020-03-09 Thread Marco Bodrato
Ciao, Il 2020-03-09 13:04 minux ha scritto: Hello, IMO, it's better to keep behavior of mini-gmp and gmp as consistent as possible, to minimize surprises. I agree! I added a check for out-of-range base to the beginning of mpq_get_str I'd prefer to let checking ranges outside of the mpq

Re: mpz_prevprime

2020-03-09 Thread Marco Bodrato
Ciao, Il 2020-03-09 11:59 Seth Troisi ha scritto: On Mon, Mar 9, 2020 at 2:05 AM Marco Bodrato wrote: Ciao, Il 2020-03-09 02:56 Seth Troisi ha scritto: It's highly possible I misunderstand how these macros are supposed to be used. I also dislike the boiler plate of the macros but I didn't

Re: [PATCH] mini-gmp: pass correct old_size to custom reallocate function

2020-03-09 Thread minux
Hello, On Mon, Mar 9, 2020 at 6:23 AM Marco Bodrato wrote: > > Ciao, > > Il 2020-03-07 21:27 minux ha scritto: > > All comments addressed, except as noted below. > > I also fixed similar issues in mini-mpq.c changes. > > > > On Sat, Mar 7, 2020 at 2:26 PM Niels Möller > > wrote: > >> minux writ

Re: [PATCH] mini-gmp: pass correct old_size to custom reallocate function

2020-03-09 Thread Niels Möller
Marco Bodrato writes: > For the style, I do not know which one is better: > "if(c){v=val}else{v=0};" or "v=0;if(c){v=val};" I don't have a very strong opinion on this point, but when it's easy to do, I prefer to assign once on each code path. Then one (i) doesn't have to reason about mutated val

Re: mpz_prevprime

2020-03-09 Thread Seth Troisi
On Mon, Mar 9, 2020 at 2:05 AM Marco Bodrato wrote: > Ciao, > > Il 2020-03-09 02:56 Seth Troisi ha scritto: > > From Marco Bodrato's analysis I got inspired and modified nextprime to > > Your analysis is much deeper than mine :-) > I do not have much time now... but I glanced at the code and writ

Re: [PATCH] mini-gmp: pass correct old_size to custom reallocate function

2020-03-09 Thread Marco Bodrato
Ciao, Il 2020-03-07 21:27 minux ha scritto: All comments addressed, except as noted below. I also fixed similar issues in mini-mpq.c changes. On Sat, Mar 7, 2020 at 2:26 PM Niels Möller wrote: minux writes: I'm not that familiar with the mpq functions. I hope Marco can comment. I had p

Re: mpz_prevprime

2020-03-09 Thread Marco Bodrato
Ciao, Il 2020-03-09 02:56 Seth Troisi ha scritto: From Marco Bodrato's analysis I got inspired and modified nextprime to Your analysis is much deeper than mine :-) I do not have much time now... but I glanced at the code and write here a few comments. You can see some of my thresholds and