00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifdef USE_PCH
00043 #include "cg_pch.h"
00044 #endif // USE_PCH
00045 #pragma hdrstop
00046
00047 #ifdef _KEEP_RCS_ID
00048 static char *rcs_id = "$Source: /scratch/mee/2.4-65/kpro64-pending/be/cg/gra_mon/SCCS/s.gra_lrange_subuniverse.cxx $ $Revision: 1.2 $";
00049 #endif
00050
00051 #include "defs.h"
00052 #include "mempool.h"
00053 #include "gra_bb.h"
00054 #include "gra_trace.h"
00055 #include "gra_lrange.h"
00056 #include "gra_lrange_subuniverse.h"
00057
00058 LRANGE_SUB_MGR lrange_sub_mgr;
00059
00060 LRANGE*
00061 INT_LRANGE_Sub(INT i, LRANGE_SET_SUBUNIVERSE *sub)
00062 {
00063 return sub->Nth_Lrange(i);
00064 }
00065
00067
00068
00069
00070
00071 LRANGE*
00072 LRANGE_SET_SUBUNIVERSE::Nth_Lrange(INT i)
00073 {
00074 DevAssert(i !=-1,("Choose failure passed to LRANGE_SET_SUBUNIVERSE::Nth_Lrange"));
00075 DevAssert(i < Count(), ("LRANGE_SET_SUBUNIVERSE index out of range %d vs %d",
00076 i, Count()));
00077 return Lranges()[i];
00078 }
00079
00081
00082
00083 void
00084 LRANGE_SUB_MGR::Initialize(void)
00085 {
00086 if ( ! pool_initialized ) {
00087 MEM_POOL_Initialize(&pool,"GRA lrange universe pool",FALSE);
00088 MEM_POOL_Push(&pool);
00089 pool_initialized = TRUE;
00090 }
00091 }
00092
00094
00095
00096
00097 void
00098 LRANGE_SUB_MGR::Finalize(void)
00099 {
00100 if (pool_initialized) {
00101 MEM_POOL_Pop(&pool);
00102 MEM_POOL_Delete(&pool);
00103 pool_initialized = FALSE;
00104 }
00105 }
00106
00108
00109
00110 LRANGE_SUBUNIVERSE*
00111 LRANGE_SUB_MGR::Create(INT32 initial_size)
00112 {
00113 LRANGE_SUBUNIVERSE* result = TYPE_MEM_POOL_ALLOC(LRANGE_SUBUNIVERSE, &pool);
00114 result->count = 0;
00115 result->alloc_size = initial_size;
00116 result->lranges = TYPE_MEM_POOL_ALLOC_N(LRANGE*,&pool,initial_size);
00117 return result;
00118 }
00119
00121
00122
00123 void
00124 LRANGE_SET_SUBUNIVERSE::Add(LRANGE* lrange)
00125 {
00126 INT32 id = count++;
00127
00128 if (count >= alloc_size) {
00129
00130 INT32 new_alloc_size = alloc_size * 2;
00131 GRA_Trace_Memory_Realloc("LRANGE_SET_SUBUNIVERSE::Add()");
00132
00133 lranges = TYPE_MEM_POOL_REALLOC_N(LRANGE*, &lrange_sub_mgr.pool, lranges,
00134 alloc_size, new_alloc_size);
00135 alloc_size = new_alloc_size;
00136 }
00137 lrange->Id_Set(id);
00138 lranges[id] = lrange;
00139 }