Additional memory handler features.

Niels Möller nisse at lysator.liu.se
Mon Jan 5 08:18:38 UTC 2015


Fredrik Johansson <fredrik.johansson at gmail.com> writes:

> How would this work with functions that allocate a variable amount of
> memory depending on the values of the inputs? Wouldn't you always have
> to allocate for the worst case?

It has to be sufficient for the worst case. There are also some other
requirements of the itch functions; they ought to be monotonically
increasing in input size (which isn't as easy as it sounds for, e.g.,
division functions).

> An example would be mpn_perfect_square_p, which "excludes 212/256
> (82.8%) of the perfect square candidates in O(1) time".

Interesting example, thanks. If it's a problem to allocate for the worst
case, I guess one could split this into one function doing as possible
with little storage, and returning "unknown" in the case that a square
root computation is needed.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.


More information about the gmp-devel mailing list