=?koi8-r?Q?Re=3A_[Gc]=3A_Patches_for_C++_to_support_throw()_declarations, _and_that_throwstd=3A=3Abad=5Falloc_on_OOM.?=

Ivan Maidanski ivmai at mail.ru
Mon Nov 9 02:43:12 PST 2009


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.


More information about the Gc mailing list