[Gc] Resubmitted: Patch that adds throw of std::bad_alloc for GC'd
Gtalbot at locuspharma.com
Fri May 29 05:32:05 PDT 2009
(resubmitted as unified diff (-ruN) using "cvs diff -ruN", as an attachment instead of inline in the email)
For my C++ app, I needed to be able to detect out of memory in a way that
follows the standard somewhat, in that operator new should throw
std::bad_alloc if it fails. This patch accomplishes this by adding "throw
(std::bad_alloc)" to the existing declarations of operator new, and
declaring a second version that takes const nothrow_t as a parameter and
catches the exception if allocation fails (and returns zero in that case).
To enable the throwing behavior, I added a class at the top of the file,
gc_cpp_init, that initializes the GC and installs an out-of-memory handler
that calls the existing C++ new handler, if installed, or throws
Also adds placement options for ignore-off-page, which I needed when
allocating some large I/O caches in my app.
Let me know if this works for you.
Tested on Linux x86_64, gcc 4.1.3
George T. Talbot
<gtalbot at locuspharma.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 10026 bytes
Url : https://napali.hpl.hp.com/pipermail/gc/attachments/20090529/ad240a9c/gc_cpp_h.obj
More information about the Gc