TCNewEnable.h

Go to the documentation of this file.
00001 //*******************************************************************************
00002 //
00003 // *******   ***   ***               *
00004 //    *     *     *                  *
00005 //    *    *      *                *****
00006 //    *    *       ***  *   *   **   *    **    ***
00007 //    *    *          *  * *   *     *   ****  * * *
00008 //    *     *         *   *      *   * * *     * * *
00009 //    *      ***   ***    *     **   **   **   *   *
00010 //                        *
00011 //*******************************************************************************
00012 // see http://sourceforge.net/projects/tcsystem/ for details.
00013 // Copyright (C) 2003 - 2008 Thomas Goessler. All Rights Reserved. 
00014 //*******************************************************************************
00015 //
00016 // TCSystem is the legal property of its developers.
00017 // Please refer to the COPYRIGHT file distributed with this source distribution.
00018 // 
00019 // This library is free software; you can redistribute it and/or             
00020 // modify it under the terms of the GNU Lesser General Public                
00021 // License as published by the Free Software Foundation; either              
00022 // version 2.1 of the License, or (at your option) any later version.        
00023 //                                                                           
00024 // This library is distributed in the hope that it will be useful,           
00025 // but WITHOUT ANY WARRANTY; without even the implied warranty of            
00026 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         
00027 // Lesser General Public License for more details.                           
00028 //                                                                           
00029 // You should have received a copy of the GNU Lesser General Public          
00030 // License along with this library; if not, write to the Free Software       
00031 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
00032 //*******************************************************************************
00033 //  $Id: TCNewEnable.h 823 2008-02-12 22:12:32Z the_____tiger $
00034 //*******************************************************************************
00035 
00036 #ifndef _TC_NEW_ENABLE_H_
00037 #define _TC_NEW_ENABLE_H_
00038 
00051 // if debug we enable memory checking
00052 #if defined DEBUG || defined _DEBUG
00053 
00054 #  ifndef TC_USE_MEM_CHECK
00055 #     define TC_USE_MEM_CHECK 1
00056 #  endif
00057 
00058 #else
00059 #  ifdef TC_USE_MEM_CHECK
00060 #     undef TC_USE_MEM_CHECK
00061 #  endif
00062 #  define TC_USE_MEM_CHECK 0
00063 
00064 #endif
00065 
00066 #if TC_USE_MEM_CHECK
00067 
00068 # include <new>
00069 
00070 #if TCOS_LINUX || TCOS_AIX || TCOS_SUN || TCOS_CYGWIN
00071 #  define TC_NEW_THROW   throw(std::bad_alloc)
00072 #  define TC_DEL_THROW   throw()
00073 #  define TC_CRT_DECL
00074 #elif TCOS_OSF1
00075 #  define TC_NEW_THROW   _RWSTD_THROW_SPEC((std::bad_alloc))
00076 #  define TC_DEL_THROW   _RWSTD_THROW_SPEC_NULL
00077 #  define TC_CRT_DECL
00078 #elif TCOS_HP
00079 #  define TC_NEW_THROW   __THROWSPEC_X(__bad_alloc)
00080 #  define TC_DEL_THROW   __THROWSPEC_NULL
00081 #  define TC_CRT_DECL
00082 #elif TCOS_WINDOWS
00083 #  if _MSC_VER
00084 #    define TC_NEW_THROW   _THROW1(std::bad_alloc)
00085 #    define TC_DEL_THROW   _THROW0()
00086 #    define TC_CRT_DECL    __cdecl
00087 #  else
00088 #    define TC_NEW_THROW
00089 #    define TC_DEL_THROW
00090 #    define TC_CRT_DECL
00091 #  endif
00092 #else
00093 #  define TC_NEW_THROW
00094 #  define TC_DEL_THROW
00095 #  define TC_CRT_DECL
00096 #endif
00097 
00098 // __cdecl
00099 void* TC_CRT_DECL operator new(std::size_t size) TC_NEW_THROW;
00100 void* TC_CRT_DECL operator new[](std::size_t size) TC_NEW_THROW;
00101 void* TC_CRT_DECL operator new(std::size_t size, const char *fileName, int line) TC_NEW_THROW;
00102 void* TC_CRT_DECL operator new[](std::size_t size, const char *fileName, int line) TC_NEW_THROW;
00103 
00104 void TC_CRT_DECL operator delete(void *p) TC_DEL_THROW;
00105 void TC_CRT_DECL operator delete[](void *p) TC_DEL_THROW;
00106 void TC_CRT_DECL operator delete(void *p, const char *fileName, int line) TC_DEL_THROW;
00107 void TC_CRT_DECL operator delete[](void *p, const char *fileName, int line) TC_DEL_THROW;
00108 
00109 # define TC_NEW new(__FILE__, __LINE__)
00110 # define new     TC_NEW
00111 
00112 #endif // _TC_NEW_ENABLE_H_
00113 
00118 #endif // DBG_NEW_ENABLE_H

Copyright (c) Thomas Goessler 2003 - 2008