[Gc] GC and dynamic libraries

Joris van der Hoeven vdhoeven at texmacs.org
Wed Jun 23 08:26:30 PDT 2004


Hi,

In despair, I continued to try making the STL use GC,
even though this might not be the source of my problems.
I hope that there is a systematic way to do use GC
in combination with the STL. What about the following code:

#ifdef SUPPORTS_GC
#include <gc/new_gc_alloc.h>
#include <new>
inline void* operator new(std::size_t sz) throw (std::bad_alloc) { return GC_MALLOC (sz); }
inline void* operator new[](std::size_t sz) throw (std::bad_alloc) { return GC_MALLOC (sz); }
inline void operator delete(void*) throw() {}
inline void operator delete[](void*) throw() {}
inline void* operator new(std::size_t sz, const std::nothrow_t& dummy) throw() {return GC_MALLOC (sz); }
inline void* operator new[](std::size_t sz, const std::nothrow_t& dummy) throw() { return GC_MALLOC (sz); }
inline void operator delete(void*, const std::nothrow_t& dummy) throw() {}
inline void operator delete[](void*, const std::nothrow_t& dummy) throw() {}
#endif

Unfortunately, this still does not work with dynamic libraries...

As I mentioned in my previous email, malloc never seems to be called though,
so it is very plausable that my problems actually do not stem from the STL,
but from GC itself.

Best wishes, Joris



More information about the Gc mailing list