00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2005 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 Version 2.4 (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.systemc.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 *****************************************************************************/ 00025 00026 /***************************************************************************** 00027 00028 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 00029 changes you are making here. 00030 00031 Name, Affiliation, Date: 00032 Description of Modification: 00033 00034 *****************************************************************************/ 00035 00036 #ifndef SC_MEMPOOL_H 00037 #define SC_MEMPOOL_H 00038 00039 00040 #include "sysc/utils/sc_iostream.h" 00041 00042 namespace sc_core { 00043 00044 // ---------------------------------------------------------------------------- 00045 // CLASS : sc_mempool 00046 // 00047 // ... 00048 // ---------------------------------------------------------------------------- 00049 00050 class sc_mempool 00051 { 00052 public: 00053 00054 static void* allocate( size_t sz ); 00055 static void release( void* p, size_t sz ); 00056 static void display_statistics(); 00057 }; 00058 00059 00060 // ---------------------------------------------------------------------------- 00061 // CLASS : sc_mpobject 00062 // 00063 // ... 00064 // ---------------------------------------------------------------------------- 00065 00066 class sc_mpobject 00067 { 00068 public: 00069 00070 static void* operator new( size_t sz ) 00071 { return sc_mempool::allocate( sz ); } 00072 00073 static void operator delete( void* p, size_t sz ) 00074 { sc_mempool::release( p, sz ); } 00075 00076 static void* operator new[]( size_t sz ) 00077 { return sc_mempool::allocate( sz ); } 00078 00079 static void operator delete[]( void* p, size_t sz ) 00080 { sc_mempool::release( p, sz ); } 00081 }; 00082 00083 } // namespace sc_core 00084 00085 #endif