System documentation of the GNU Image-Finding Tool

Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members

myNew.h

00001 // -*- mode: c++ -*-
00002 #ifndef _MYNEW
00003 #define _MYNEW
00004 /* -*- mode: c++ -*- 
00005 */
00006 /* 
00007 
00008     GIFT, a flexible content based image retrieval system.
00009     Copyright (C) 1998, 1999, 2000, 2001, 2002, CUI University of Geneva
00010 
00011     This program is free software; you can redistribute it and/or modify
00012     it under the terms of the GNU General Public License as published by
00013     the Free Software Foundation; either version 2 of the License, or
00014     (at your option) any later version.
00015 
00016     This program is distributed in the hope that it will be useful,
00017     but WITHOUT ANY WARRANTY; without even the implied warranty of
00018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019     GNU General Public License for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with this program; if not, write to the Free Software
00023     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024 
00025 */
00026 #include <iostream>
00027 #include <cstdlib>
00028 #include "libMRML/include/CDebuggingMemoryManager.h"
00029 
00030 //#define __memdebug
00031 
00032 void* operator new(size_t s){
00033   if(gMemManager.isValid()){
00034 
00035 #ifdef __memdebug
00036     cout << "MyAlloc" << s << endl;
00037 #endif
00038     return gMemManager.getMem(s);
00039   }
00040 #ifdef __memdebug
00041   cout << "NormalAlloc" << flush;
00042 #endif
00043   return malloc(s);
00044 }
00045 /* void* operator new[](size_t s){ */
00046 /*   return new(s); */
00047 /* } */
00048 
00049 void operator delete(void * inToBeDeleted){
00050   if(inToBeDeleted){
00051     if(gMemManager.freeMem(inToBeDeleted)){
00052 #ifdef __memdebug
00053       cout << "°my[" 
00054            << inToBeDeleted 
00055            << "]" 
00056            << flush;// a character for which one can grep
00057 #endif
00058       return;
00059     }else{
00060 #ifdef __memdebug
00061       cout << "§pre[" 
00062            << inToBeDeleted 
00063            << "]" 
00064            << flush;// a character for which one can grep
00065 #endif
00066       free(inToBeDeleted);
00067     }
00068   }else{
00069     cout << "!null" << endl;
00070   }
00071 }
00072 
00073 void operator delete[](void* inToBeDeleted){ 
00074   delete(inToBeDeleted); 
00075 } 
00076 
00077 #endif

Need for discussion? Want to contribute? Contact
help-gift@gnu.org Generated using Doxygen