[Gc] Patches for C++ to support throw() declarations, and that throw std::bad_alloc on OOM.

Talbot, George Gtalbot at ansarisbio.com
Fri Nov 6 06:34:21 PST 2009


Hi folks,

I think I may have submitted an earlier, messier version of this patch.  This version is much cleaner.

This patch should be source-compatible with C++ programs and does the following:

*  Adds throw() declarations to the new operators that the collector provides in gc_cpp.h, according to the standard.
*  Adds a gc_cpp_init() that installs an OOM proc that throws std::bad_alloc if the collector runs out of memory.

Slightly more controversially:

*  The standard operator new that gc_cpp.h and gc_cpp.cc provides allocates memory with GC_MALLOC() instead of GC_MALLOC_UNCOLLECTABLE().

I was trying to figure out how to be able to switch this without recompiling the collector, but if I add a function to change the behavior then the behavior doesn't change until the function is called.  This is problematic for objects that are allocated before main() runs.  Any suggestions here would be helpful.

Can this go in?  I think it's probably a lot less invasive (intentionally so) than the last time I tried to submit it.

--
George T. Talbot
<gtalbot at ansarisbio.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gc-cpp-throw.patch
Type: text/x-diff
Size: 14394 bytes
Desc: gc-cpp-throw.patch
Url : http://napali.hpl.hp.com/pipermail/gc/attachments/20091106/5d85b363/gc-cpp-throw.bin


More information about the Gc mailing list