]> granicus.if.org Git - gc/commitdiff
put all the cpp stuff in header
authorJohannes Totz <jtotz@ic.ac.uk>
Tue, 13 Jul 2010 14:14:53 +0000 (15:14 +0100)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 11 May 2015 16:00:05 +0000 (19:00 +0300)
otherwise vc9 will mix up new and delete operators (due to arbitrary ordering during linking)

Conflicts:

gc_cpp.cc
include/gc_cpp.h

gc_cpp.cc
include/gc_cpp.h

index 0f6c9d2b1dde78681ec9109caf8691fd69d8ac0e..279ccf46f5f058357cc9789816616fb127193d31 100644 (file)
--- a/gc_cpp.cc
+++ b/gc_cpp.cc
@@ -43,46 +43,44 @@ built-in "new" and "delete".
 # define GC_DECL_DELETE_THROW /* empty */
 #endif /* !GC_NEW_DELETE_NEED_THROW */
 
-void* operator new( size_t size ) GC_DECL_NEW_THROW {
-  return GC_MALLOC_UNCOLLECTABLE(size);
-}
-
-#if !defined(__CYGWIN__)
-  void operator delete( void* obj ) GC_DECL_DELETE_THROW {
-    GC_FREE(obj);
-  }
-#endif /* !__CYGWIN__ */
-
-#ifdef GC_OPERATOR_NEW_ARRAY
-  void* operator new[]( size_t size ) GC_DECL_NEW_THROW {
-    return GC_MALLOC_UNCOLLECTABLE(size);
-  }
-
-  void operator delete[]( void* obj ) GC_DECL_DELETE_THROW {
-    GC_FREE(obj);
-  }
-#endif /* GC_OPERATOR_NEW_ARRAY */
-
-#ifdef _MSC_VER
-
-  // This new operator is used by VC++ in case of Debug builds!
-  void* operator new( size_t size, int /* nBlockUse */,
-                     const char * szFileName, int nLine ) GC_DECL_NEW_THROW
-  {
-#   ifndef GC_DEBUG
-      return GC_malloc_uncollectable(size);
-#   else
-      return GC_debug_malloc_uncollectable(size, szFileName, nLine);
-#   endif
-  }
-
-# if _MSC_VER > 1020
-    // This new operator is used by VC++ 7.0 and later in Debug builds.
-    void* operator new[]( size_t size, int nBlockUse,
-                         const char* szFileName, int nLine ) GC_DECL_NEW_THROW
-    {
-      return operator new(size, nBlockUse, szFileName, nLine);
-    }
-# endif
-
-#endif /* _MSC_VER */
+// MOVED TO HEADER!
+//void* operator new( size_t size ) {
+//    return GC_MALLOC_UNCOLLECTABLE( size );}
+//
+//void operator delete( void* obj ) {
+//    GC_FREE( obj );}
+//
+//#ifdef GC_OPERATOR_NEW_ARRAY
+//
+//void* operator new[]( size_t size ) {
+//    return GC_MALLOC_UNCOLLECTABLE( size );}
+//
+//void operator delete[]( void* obj ) {
+//    GC_FREE( obj );}
+//
+//#endif /* GC_OPERATOR_NEW_ARRAY */
+//
+//#ifdef _MSC_VER
+//
+//// This new operator is used by VC++ in case of Debug builds !
+//void* operator new( size_t size,
+//                          int ,//nBlockUse,
+//                          const char * szFileName,
+//                          int nLine )
+//{
+//#ifndef GC_DEBUG
+//        return GC_malloc_uncollectable( size );
+//#else
+//        return GC_debug_malloc_uncollectable(size, szFileName, nLine);
+//#endif
+//}
+//
+//#if _MSC_VER > 1020
+//// This new operator is used by VC++ 7.0 and later in Debug builds.
+//void* operator new[](size_t size, int nBlockUse, const char* szFileName, int nLine)
+//{
+//    return operator new(size, nBlockUse, szFileName, nLine);
+//}
+//#endif
+//
+//#endif /* _MSC_VER */
index b4fe6daaea856a0bbaf8b132dffa431a5f1caf48..35b5b63178ef9c537499d702641e95d00150ebee 100644 (file)
@@ -278,17 +278,48 @@ inline void* operator new( size_t size, GC_NS_QUALIFY(GCPlacement) gcp,
   *  There seems to be no way to redirect new in this environment without
   *  including this everywhere.
   */
-# if _MSC_VER > 1020
-    void *operator new[]( size_t size );
-    void operator delete[]( void* obj );
-# endif
+#if _MSC_VER > 1020
+inline void *operator new[]( size_t size ){
+    return GC_MALLOC_UNCOLLECTABLE( size );}
+
+inline void operator delete[]( void* obj ) {
+    GC_FREE( obj );}
+
+#endif
+
 
-  void* operator new( size_t size );
-  void operator delete( void* obj );
+// void* operator new( size_t size);
+// void operator delete(void* obj);
+
+    // MOVED HERE FROM gc_hpp.cc!
+    inline void* operator new(size_t size)
+    {
+        return GC_MALLOC_UNCOLLECTABLE(size);
+    }
+
+    inline void operator delete(void* obj)
+    {
+        GC_FREE(obj);
+    }
+
+
+ // This new operator is used by VC++ in case of Debug builds !
+ inline void* operator new(  size_t size,
+                      int ,//nBlockUse,
+                      const char * szFileName,
+                      int nLine )
+    {
+#ifndef GC_DEBUG
+            return GC_malloc_uncollectable( size );
+#else
+            return GC_debug_malloc_uncollectable(size, szFileName, nLine);
+#endif
+    }
+inline void* operator new[](size_t size, int nBlockUse, const char* szFileName, int nLine)
+{
+    return operator new(size, nBlockUse, szFileName, nLine);
+}
 
-  // This new operator is used by VC++ in case of Debug builds !
-  void* operator new( size_t size, int /* nBlockUse */,
-                     const char * szFileName, int nLine );
 #endif /* _MSC_VER */
 
 #ifdef GC_OPERATOR_NEW_ARRAY