0029151: GCC 7.1 warnings "this statement may fall through" [-Wimplicit-fallthrough=]
[occt.git] / src / NCollection / NCollection_DefineAlloc.hxx
1 // Created on: 2012-01-19
2 // Created by: Dmitry BOBYLEV 
3 // Copyright (c) 2012-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _NCollection_DefineAlloc_HeaderFile
17 # define _NCollection_DefineAlloc_HeaderFile
18
19 #include <NCollection_BaseAllocator.hxx>
20
21 // Macro to overload placement new and delete operators for NCollection allocators.
22 // For Borland C and old SUN compilers do not define placement delete
23 // as it is not supported.
24 # if defined(__BORLANDC__) || (defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530))
25 #  define DEFINE_NCOLLECTION_ALLOC                                               \
26    void* operator new (size_t theSize,                                           \
27                        const Handle(NCollection_BaseAllocator)& theAllocator)    \
28    {                                                                             \
29      return theAllocator->Allocate(theSize);                                     \
30    }
31 # else
32 #  define DEFINE_NCOLLECTION_ALLOC                                               \
33    void* operator new (size_t theSize,                                           \
34                        const Handle(NCollection_BaseAllocator)& theAllocator)    \
35    {                                                                             \
36      return theAllocator->Allocate(theSize);                                     \
37    }                                                                             \
38    void  operator delete (void* theAddress,                                      \
39                           const Handle(NCollection_BaseAllocator)& theAllocator) \
40    {                                                                             \
41      theAllocator->Free(theAddress);                                             \
42    }
43 # endif
44
45 #endif