00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2014 by all Contributors. 00005 All Rights reserved. 00006 00007 The contents of this file are subject to the restrictions and limitations 00008 set forth in the SystemC Open Source License (the "License"); 00009 You may not use this file except in compliance with such restrictions and 00010 limitations. You may obtain instructions on how to receive a copy of the 00011 License at http://www.accellera.org/. Software distributed by Contributors 00012 under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF 00013 ANY KIND, either express or implied. See the License for the specific 00014 language governing rights and limitations under the License. 00015 00016 *****************************************************************************/ 00017 00018 /***************************************************************************** 00019 00020 sc_mempool.h - Memory pools for small objects. 00021 00022 Original Author: Stan Y. Liao, Synopsys, Inc. 00023 00024 CHANGE LOG AT END OF FILE 00025 *****************************************************************************/ 00026 00027 #ifndef SC_MEMPOOL_H 00028 #define SC_MEMPOOL_H 00029 00030 00031 #include "sysc/utils/sc_iostream.h" 00032 00033 namespace sc_core { 00034 00035 // ---------------------------------------------------------------------------- 00036 // CLASS : sc_mempool 00037 // 00038 // ... 00039 // ---------------------------------------------------------------------------- 00040 00041 class sc_mempool 00042 { 00043 public: 00044 00045 static void* allocate( std::size_t sz ); 00046 static void release( void* p, std::size_t sz ); 00047 static void display_statistics(); 00048 }; 00049 00050 00051 // ---------------------------------------------------------------------------- 00052 // CLASS : sc_mpobject 00053 // 00054 // ... 00055 // ---------------------------------------------------------------------------- 00056 00057 class sc_mpobject 00058 { 00059 public: 00060 00061 static void* operator new( std::size_t sz ) 00062 { return sc_mempool::allocate( sz ); } 00063 00064 static void operator delete( void* p, std::size_t sz ) 00065 { sc_mempool::release( p, sz ); } 00066 00067 static void* operator new[]( std::size_t sz ) 00068 { return sc_mempool::allocate( sz ); } 00069 00070 static void operator delete[]( void* p, std::size_t sz ) 00071 { sc_mempool::release( p, sz ); } 00072 }; 00073 00074 } // namespace sc_core 00075 00076 // $Log: sc_mempool.h,v $ 00077 // Revision 1.3 2011/08/26 20:46:18 acg 00078 // Andy Goodrich: moved the modification log to the end of the file to 00079 // eliminate source line number skew when check-ins are done. 00080 // 00081 // Revision 1.2 2011/02/18 20:38:44 acg 00082 // Andy Goodrich: Updated Copyright notice. 00083 // 00084 // Revision 1.1.1.1 2006/12/15 20:20:06 acg 00085 // SystemC 2.3 00086 // 00087 // Revision 1.3 2006/01/13 18:53:11 acg 00088 // Andy Goodrich: Added $Log command so that CVS comments are reproduced in 00089 // the source. 00090 00091 #endif