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

Talbot, George Gtalbot at ansarisbio.com
Mon Nov 9 03:23:09 PST 2009


Thank you for reviewing this.  I will make the changes on Wednesday and re-submit.

--
George T. Talbot
<gtalbot at ansarisbio.com>
________________________________________
From: gc-bounces at napali.hpl.hp.com [gc-bounces at napali.hpl.hp.com] On Behalf Of Ivan Maidanski [ivmai at mail.ru]
Sent: Monday, November 09, 2009 5:43 AM
To: gc at napali.hpl.hp.com
Cc: Talbot, George
Subject: Re: [Gc]: Patches for C++ to support throw() declarations,      and that throwstd::bad_alloc on OOM.

Hi!
"Talbot, George" <Gtalbot at ansarisbio.com> wrote:
> Hi folks,
>
> I think I may have submitted an earlier, messier version of this patch.  This version is much cleaner.
> ...
> *  Adds a gc_cpp_init() that installs an OOM proc that throws std::bad_alloc if the collector runs out of memory.

Minor tips:

1. It's better to call GC_INIT() from a macro (or at last from an inline func) since GC_INIT() is tunable from the client code (eg. #define GC_CPP_INIT() { GC_INIT(); GC_set_oom_fn(GC_cpp_oom_fn); } where gc_cpp_oom_fn renamed to GC_cpp_oom_fn and declared in gc_cpp.h with GC_API);

2. It's better to use GC_set_oom_fn() instead of assigning GC_oom_fn directly;

3. It's better to use GC_CALLBACK for gc_cpp_oom_fn() (void* GC_CALLBACK gc_cpp_oom_fn(size_t));

4. Indentation in gc_cpp.h:
     && (defined(__BORLANDC__) && (__BORLANDC__ < 0x450) \
-        || (defined(__GNUC__) && \
-            (__GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 6)) \
-        || (defined(__WATCOMC__) && __WATCOMC__ < 1050))
+    || (defined(__GNUC__) && \
+        (__GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 6)) \
+    || (defined(__WATCOMC__) && __WATCOMC__ < 1050))

I think this fragment already has proper indentation, so this patch fragment shouldn't be applied.

Bye.
_______________________________________________
Gc mailing list
Gc at linux.hpl.hp.com
http://www.hpl.hp.com/hosted/linux/mail-archives/gc/



More information about the Gc mailing list