TCDebugNew.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: TCDebugNew.h 833 2008-03-27 21:28:38Z the_____tiger $
00034 //*******************************************************************************
00035 #include "TCNew.h"
00036 
00037 #include "TCNewEnable.h"
00038 #include "TCNewDisable.h"
00039 
00040 #include <stdlib.h>
00041 
00042 #if TC_USE_MEM_CHECK
00043 
00044 void *operator new(size_t size) TC_NEW_THROW
00045 {
00046    return TC::New::GetInstance()->Allocate(static_cast<TC::uint32>(size), "unknown new", 0);
00047 }
00048 void *operator new[](size_t size) TC_NEW_THROW
00049 {
00050    return TC::New::GetInstance()->Allocate(static_cast<TC::uint32>(size), "unknown new[]", 1);
00051 }
00052 void *operator new(size_t size, const char *fileName, int line) TC_NEW_THROW
00053 {
00054    return TC::New::GetInstance()->Allocate(static_cast<TC::uint32>(size), fileName, line);
00055 }
00056 void *operator new[](size_t size, const char *fileName, int line) TC_NEW_THROW
00057 {
00058    return TC::New::GetInstance()->Allocate(static_cast<TC::uint32>(size), fileName, line);
00059 }
00060 
00061 void operator delete(void *p) TC_DEL_THROW
00062 {
00063    if (TC::New::GetInstance())
00064       TC::New::GetInstance()->Free(p);
00065    else
00066       free(p);
00067 }
00068 
00069 void operator delete[](void *p) TC_DEL_THROW
00070 {
00071    if (TC::New::GetInstance())
00072       TC::New::GetInstance()->Free(p);
00073    else
00074       free(p);
00075 }
00076 void operator delete(void *p, const char *, int) TC_DEL_THROW
00077 {
00078    if (TC::New::GetInstance())
00079       TC::New::GetInstance()->Free(p);
00080    else
00081       free(p);
00082 }
00083 void operator delete[](void *p, const char *, int) TC_DEL_THROW
00084 {
00085    if (TC::New::GetInstance())
00086       TC::New::GetInstance()->Free(p);
00087    else
00088       free(p);
00089 }
00090 
00091 #endif

Copyright (c) Thomas Goessler 2003 - 2008