Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

NoDelete.C

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 
00003 // This file is part of Vesta.
00004 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // Last modified on Sat May  7 17:17:00 EDT 2005 by ken@xorian.net        
00020 //      modified on Sun Jul 28 11:40:34 EDT 2002 by lken@remote.xorian.net
00021 //      modified on Wed Dec 27 13:58:29 PST 1995 by heydon
00022 
00023 #include <sys/types.h> // for "size_t"
00024 
00025 #include <new> // std::bad_alloc
00026 
00027 #include "Basics.H"    // for Basics::gc_attribs
00028 
00029 Basics::gc_no_pointers_t Basics::gc_no_pointers;
00030 
00031 // Define our allocation function as a pass-through to the normal new
00032 // operator.
00033 
00034 void *operator new(size_t size, Basics::gc_no_pointers_t unused,
00035                    const char *file, unsigned int line)
00036 {
00037   void *result;
00038   try
00039     {
00040       result = ::operator new(size);
00041     }
00042   catch (std::bad_alloc)
00043     {
00044       std::cerr << "Out of memory trying to allocate "
00045                 << size << " bytes at "
00046                 << file << ":" << line << std::endl;
00047       abort();
00048     }
00049   return result;
00050 }
00051 
00052 void *operator new[](size_t size, Basics::gc_no_pointers_t unused,
00053                      const char *file, unsigned int line)
00054 {
00055   void *result;
00056   try
00057     {
00058       result = ::operator new[](size);
00059     }
00060   catch (std::bad_alloc)
00061     {
00062       std::cerr << "Out of memory trying to allocate "
00063                 << size << " bytes at "
00064                 << file << ":" << line << std::endl;
00065       abort();
00066     }
00067   return result;
00068 }
00069 
00070 void *operator new(size_t size, const char *file, unsigned int line)
00071 {
00072   void *result;
00073   try
00074     {
00075       result = ::operator new(size);
00076     }
00077   catch (std::bad_alloc)
00078     {
00079       std::cerr << "Out of memory trying to allocate "
00080                 << size << " bytes at "
00081                 << file << ":" << line << std::endl;
00082       abort();
00083     }
00084   return result;
00085 }
00086 
00087 void *operator new[](size_t size, const char *file, unsigned int line)
00088 {
00089   void *result;
00090   try
00091     {
00092       result = ::operator new[](size);
00093     }
00094   catch (std::bad_alloc)
00095     {
00096       std::cerr << "Out of memory trying to allocate "
00097                 << size << " bytes at "
00098                 << file << ":" << line << std::endl;
00099       abort();
00100     }
00101   return result;
00102 }
00103 
00104 // Define a version of "delete" that's a no-op.
00105 
00106 void operator delete(void *p) { /*SKIP*/ }
00107 void operator delete[](void *p) { /*SKIP*/ }

Generated on Mon May 8 00:48:28 2006 for Vesta by  doxygen 1.4.2