Correction of merge results
[occt.git] / src / Standard / Standard_DefineAlloc.hxx
1 // File:        Standard_DefineAlloc.hxx
2 // Created:     Jan 19 10:33:16 2012
3 // Author:      Dmitry BOBYLEV 
4 // Copyright:   Open CASCADE SAS 2012
5
6 #ifndef _Standard_DefineAlloc_HeaderFile
7 # define _Standard_DefineAlloc_HeaderFile
8
9 // Macro to override new and delete operators for arrays.
10 // Defined to empty for old SUN compiler
11 # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)
12 #  define DEFINE_STANDARD_ALLOC_ARRAY
13 # else
14 #  define DEFINE_STANDARD_ALLOC_ARRAY                                  \
15    void* operator new[] (size_t theSize)                               \
16    {                                                                   \
17      return Standard::Allocate (theSize);                              \
18    }                                                                   \
19    void  operator delete[] (void* theAddress)                          \
20    {                                                                   \
21      Standard::Free (theAddress);                                      \
22    }
23 # endif
24
25 // Macro to override placement new and placement delete operators. 
26 // For Borland C and old SUN compilers do not define placement delete
27 // as it is not supported.
28 # if defined(__BORLANDC__) || (defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530))
29 #  define DEFINE_STANDARD_ALLOC_PLACEMENT                              \
30    void* operator new (size_t, void* theAddress)                       \
31    {                                                                   \
32      return theAddress;                                                \
33    }
34 # else 
35 #  define DEFINE_STANDARD_ALLOC_PLACEMENT                              \
36    void* operator new (size_t, void* theAddress)                       \
37    {                                                                   \
38      return theAddress;                                                \
39    }                                                                   \
40    void operator delete (void*, void*)                                 \
41    {                                                                   \
42    }
43 # endif
44
45 // Macro to override operators new and delete to use OCC memory manager
46 # define DEFINE_STANDARD_ALLOC                                         \
47   void* operator new (size_t theSize)                                  \
48   {                                                                    \
49     return Standard::Allocate (theSize);                               \
50   }                                                                    \
51   void  operator delete (void* theAddress)                             \
52   {                                                                    \
53     Standard::Free ((Standard_Address&)theAddress);                    \
54   }                                                                    \
55   DEFINE_STANDARD_ALLOC_ARRAY                                          \
56   DEFINE_STANDARD_ALLOC_PLACEMENT
57
58 // Declare operator new in global scope for old sun compiler
59 #ifndef WORKAROUND_SUNPRO_NEW_PLACEMENT
60 #define WORKAROUND_SUNPRO_NEW_PLACEMENT
61 #if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x420)
62 inline void* operator new(size_t,void* anAddress) 
63 {
64   return anAddress;
65 }
66 #endif
67 #endif
68
69 #endif