[Kst] memory checks...
Andrew Walker
arwalker at sumusltd.com
Wed May 26 19:27:27 CEST 2004
At present kst is compiled with the -fno-check-new flag.
If a memory allocation (new) fails due to lack of memory then
the std::badalloc exception is thrown. As no exceptions are
handled in Kst the program will crash in a most ungraceful
manner.
We could either catch these exceptions, or alternatively,
could compile with the -fcheck-new flag. This flag will result
in new not throwing an exception, but will instead return NULL
for the allocated memory. Kst would then only need to check the
returned pointer on each memory allocation.
Yet another alternative would be to use new (nothrow). However,
this was added only relatively recently to g++, so may not be
available to many people.
Performing these memory checks could allow us to survive in low
memory conditions when we request a potentially very sizeable
memory allocation for a new vector. If the allocation fails we
would advise the user and Ksy would continue to run, whereas at
present it will simply crash.
Andrew
________________________________________________________________
$0 Bannerless Web Hosting, 10 POP and Web Email Accounts, & more
Get It Now At www.doteasy.com
More information about the Kst
mailing list