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

gust Namespace Reference


Compounds

class  gust::PoolChunkList

Enumerations

enum  Storage { dumb, place, heap, pool }

Functions

void release (void *buf, unsigned int t, unsigned int s)
void * reserve_global (size_t s, size_t *ret_s)
void * reserve_pool (size_t s, size_t *ret_s)
GULAPI void PoolGrow (PoolChunkList *pool)
GULAPI void PoolFreeAll (void)
void * PoolAlloc (const size_t insize, size_t *outsize)
void PoolFree (void *ptr, const size_t size)
void * PreferPoolAlloc (const size_t insize, size_t *outsize)
void PreferPoolFree (void *ptr, const size_t size)

Variables

GULAPI PoolChunkList Pools [6]
const size_t PoolTabSize = 2049
GULAPI PoolChunkListPoolTab [2049]


Enumeration Type Documentation

enum gust::Storage
 

Enumeration values:
dumb 
place 
heap 
pool 

Definition at line 42 of file gust_new.h.

00043 {
00044   dumb,
00045   place,
00046   heap,
00047   pool
00048 };


Function Documentation

void* PoolAlloc const size_t    insize,
size_t *    outsize
[inline]
 

Definition at line 133 of file gust_pool.h.

Referenced by gul::Map< kdnnrec< U, V > >::Map(), gul::RefMap::NewNode(), gul::Map< kdnnrec< U, V > >::NewNode(), gugr::edge_interval_tree::NewNode(), gul::Map< kdnnrec< U, V > >::NewNodeV(), gunu::vertex_convert_cache::operator new(), gunu::TessInfo::operator new(), gunu::SurfaceInfo::operator new(), gul::ListNode< gul::line< T > >::operator new(), gugr::GraphInfo::operator new(), gugr::segnode::operator new(), gugr::eventrec::operator new(), gugr::linepair::operator new(), gugr::linerec::operator new(), gugr::intersectionseg::operator new(), gugr::intersection::operator new(), gugr::segment::operator new(), gugr::seg_point_info::operator new(), gugr::triangle::operator new(), gugr::_cut_record::operator new(), gugr::graph_edge::operator new(), gugr::graph_vertex::operator new(), gugr::line_rep::operator new(), gugr::vertex_rep::operator new(), gul::Ptr< EP >::Ptr(), guar::rational::rational(), guar::rational::rational_rep::rational_rep(), guar::rational::rational_rep::reciprocal(), gul::RefMap::RefMap(), gul::Ptr< EP >::reset(), and gul::Ptr< EP >::use_pointer().

00134 {
00135   PoolChunkList *pool;
00136   void *head;
00137 
00138   if( !insize ) 
00139   {
00140     *outsize = 0;  
00141     return 0;
00142   }
00143   
00144   pool = PoolTab[insize];
00145 
00146   head = pool->head;
00147   
00148   if( head == NULL )
00149   {
00150     PoolGrow( pool );
00151     head = pool->head;
00152   }
00153 
00154   pool->head = *((void **)head);
00155   *outsize = pool->elemsize; 
00156 #ifdef POOLDBG
00157   new pooldbg( (void *)head, insize, *outsize );
00158 #endif
00159   return((void *)head); 
00160 }

void PoolFree void *    ptr,
const size_t    size
[inline]
 

Definition at line 162 of file gust_pool.h.

Referenced by gul::RefMap::do_destroy(), gul::RefMap::FreeNode(), gul::Map< kdnnrec< U, V > >::FreeNode(), gugr::edge_interval_tree::FreeNode(), gunu::vertex_convert_cache::operator delete(), gunu::TessInfo::operator delete(), gunu::SurfaceInfo::operator delete(), gul::ListNode< gul::line< T > >::operator delete(), gugr::GraphInfo::operator delete(), gugr::segnode::operator delete(), gugr::eventrec::operator delete(), gugr::linepair::operator delete(), gugr::linerec::operator delete(), gugr::intersectionseg::operator delete(), gugr::intersection::operator delete(), gugr::segment::operator delete(), gugr::seg_point_info::operator delete(), gugr::triangle::operator delete(), gugr::_cut_record::operator delete(), gugr::graph_edge::operator delete(), gugr::graph_vertex::operator delete(), gugr::line_rep::operator delete(), gugr::vertex_rep::operator delete(), gul::RefMap::operator=(), gul::Map< kdnnrec< U, V > >::operator=(), gul::Ptr< EP >::operator=(), gugr::line::operator=(), guar::rational::operator=(), guar::rational::rational_rep::reciprocal(), gul::Ptr< EP >::release(), gul::Ptr< EP >::reset(), gul::Map< kdnnrec< U, V > >::~Map(), gul::Ptr< EP >::~Ptr(), guar::rational::~rational(), guar::rational::rational_rep::~rational_rep(), and gul::RefMap::~RefMap().

00163 {
00164   if( !ptr || !size ) return;
00165 
00166   PoolChunkList *pool = PoolTab[size];
00167 
00168   *((void **)ptr) = pool->head;
00169   pool->head = ptr;
00170 #ifdef POOLDBG
00171   pooldbg::remove( ptr );
00172 #endif
00173 }

GULAPI void gust::PoolFreeAll void   
 

Definition at line 101 of file gust_pool.cpp.

00102 {
00103   void *ch, *next_ch;
00104   int nPools = sizeof(Pools)/sizeof(PoolChunkList), i;
00105   PoolChunkList *pool;
00106 
00107   for( i = 0; i < nPools; i++ )
00108   {
00109     pool = &Pools[i];
00110 
00111     ch = pool->chunks;
00112     while( ch )
00113     {
00114       next_ch = *((void **)ch);
00115       free( ch );
00116       ch = next_ch;
00117     }
00118     pool->head = 0;
00119     pool->chunks = 0;
00120   }
00121 }

GULAPI void gust::PoolGrow PoolChunkList   pool
 

Definition at line 74 of file gust_pool.cpp.

00075 {
00076   size_t nelems,elemsize;
00077   char *chunk,*start,*end,*p;
00078 
00079   nelems = pool->growrate;
00080   pool->growrate = nelems * 3/2;
00081   elemsize = pool->elemsize;
00082 
00083   /* important: sizeof(char) has to be ONE !!!!!!!!!!! */
00084  
00085   chunk = (char *)malloc( POOL_ALIGNMENT + nelems * elemsize );
00086   if( chunk == NULL ) return;
00087   
00088   start = chunk + POOL_ALIGNMENT;
00089   end = start + (nelems-1)*elemsize;
00090 
00091   for( p = start; p < end; p += elemsize )
00092     *((void **)p) = p + elemsize;
00093   
00094   *((void **)end) = NULL;
00095   
00096   pool->head = start;
00097   *((void **)chunk) = pool->chunks;
00098   pool->chunks = chunk;
00099 }

void* PreferPoolAlloc const size_t    insize,
size_t *    outsize
[inline]
 

Definition at line 175 of file gust_pool.h.

Referenced by gul::pool_bytealloc::allocate(), and gul::pool_object::operator new().

00176 {
00177   PoolChunkList *pool;
00178   void *head;
00179 
00180   if( !insize ) 
00181   {
00182     *outsize = 0;  
00183     return 0;
00184   }
00185 
00186   if( insize >= PoolTabSize )
00187   {
00188     *outsize = insize;
00189 
00190     void *p = malloc(insize);
00191 #ifdef POOLDBG
00192     new pooldbg( p, insize, *outsize );
00193 #endif
00194     return p;
00195   }
00196   
00197   pool = PoolTab[insize];
00198 
00199   head = pool->head;
00200   
00201   if( head == NULL )
00202   {
00203     PoolGrow( pool );
00204     head = pool->head;
00205   }
00206 
00207   pool->head = *((void **)head);
00208   *outsize = pool->elemsize; 
00209 #ifdef POOLDBG
00210   new pooldbg( (void *)head, insize, *outsize );
00211 #endif
00212   return((void *)head); 
00213 }

void PreferPoolFree void *    ptr,
const size_t    size
[inline]
 

Definition at line 215 of file gust_pool.h.

Referenced by gul::pool_bytealloc::deallocate(), gul::poolalloc::deallocate(), and gul::pool_object::operator delete().

00216 {
00217   if( !ptr || !size ) return;
00218 
00219   if( size >= PoolTabSize ) 
00220   {
00221     free(ptr);
00222 #ifdef POOLDBG
00223     pooldbg::remove( ptr );
00224 #endif
00225     return;
00226   }
00227 
00228   PoolChunkList *pool = PoolTab[size];
00229 
00230   *((void **)ptr) = pool->head;
00231   pool->head = ptr;
00232 #ifdef POOLDBG
00233   pooldbg::remove( ptr );
00234 #endif
00235 }

void release void *    buf,
unsigned int    t,
unsigned int    s
[inline]
 

Definition at line 50 of file gust_new.h.

00051 {
00052   if( (t <= place) || (buf == NULL) ) return;
00053   if( t == heap ) { free(buf); return; }
00054   PreferPoolFree( buf, s );
00055 }

void* reserve_global size_t    s,
size_t *    ret_s
[inline]
 

Definition at line 57 of file gust_new.h.

Referenced by gul::Ptr< EP >::reserve_global().

00058 {
00059   void *p = malloc( s );
00060   if( p == NULL ) throw gul::AllocError();
00061   *ret_s = s;
00062   return(p);
00063 }

void* reserve_pool size_t    s,
size_t *    ret_s
[inline]
 

Definition at line 65 of file gust_new.h.

Referenced by gul::Ptr< EP >::reserve_pool().

00066 {
00067   void *p = PreferPoolAlloc( s, ret_s);
00068   if( p == NULL ) throw gul::AllocError();
00069   return(p);
00070 }


Variable Documentation

GULAPI PoolChunkList gust::Pools
 

Initial value:

{
  { 0, 0, 4,    256 },
  { 0, 0, 8,    128 },
  { 0, 0, 16,   64  },
  { 0, 0, 64,   32  },  
  { 0, 0, 256,  16  },
  { 0, 0, 2048, 4   }
}

Definition at line 60 of file gust_pool.cpp.

Referenced by gul_halt().

GULAPI PoolChunkList * gust::PoolTab
 

Definition at line 25 of file gust_pooltbl.h.

const size_t gust::PoolTabSize = 2049
 

Definition at line 39 of file gust_pool.h.


Generated on Mon Jan 21 04:18:12 2002 for GUL 0.6 - Geometry Utility Library by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001