2 * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
3 * All rights reserved. The file named COPYRIGHT specifies the terms
4 * and conditions for redistribution.
12 #define POINTER __pset_pointer
16 * Remove all NULL pointers from a pset
18 void pset_compact( register pset_h pset )
22 for ( u = 0 ; u < pset_count( pset ) ; )
24 POINTER ptr = pset_pointer( pset, u );
28 pset_delete( pset, ptr ) ;
31 /* See if we can reclaim some memory, make sure we are 2 below for some hysteresis */
32 if ((int)( pset->max - pset->alloc_step - 2) > (int)pset_count( pset ))
33 { /* This rounds up to the next unit of steps */
35 unsigned new_max = ((pset_count( pset ) / pset->alloc_step) + 1)*pset->alloc_step;
37 new_ptrs = (POINTER *) realloc(
38 (char *)pset->ptrs, new_max * sizeof( POINTER ) ) ;
39 if ( new_ptrs == NULL )
42 pset->ptrs = new_ptrs ;
48 * Apply a function to all pointers of a pset
50 void pset_apply( register pset_h pset, void (*func)(), register void *arg )
54 for ( u = 0 ; u < pset_count( pset ) ; u++ )
56 (*func)( arg, pset_pointer( pset, u ) ) ;
58 (*func)( pset_pointer( pset, u ) ) ;