enabling exceptions in kcalc?
Evan Teran
eteran at alum.rit.edu
Thu Jan 5 19:51:12 UTC 2012
Hi,
I've been looking into creating a nice generic infrastructure for
dealing with GMP errors in kcalc. Particularly when it is asked to
calculate something massive (thing like "1234567890!" or something to
that effect).
Currently there are a couple of things going on.
GMP tries to allocate memory (and fails)
the allocator calls abort
in kcalc, for functions which are likely create massive results on big
input, i install a signal handler to catch the abort
the sig handler longjmps to an error handler within the original function
hopefully all goes well :-).
Well, it turns out that there is a much cleaner, portable and
generally easier solution ... exceptions!
GMP allows the user to specify a custom memory allocator, and I could
supply one which attempts to malloc and throws an exception if it
fails. Making the code a LOT simpler.
Currently, the kcalc build has exceptions disabled, would it be
reasonable to enable them? Is there a policy against it entirely? Or
is it just disabled by default?
Thoughts?
Evan Teran
More information about the Kde-utils-devel
mailing list