Changeset 1375
- Timestamp:
- Aug 3, 2004, 3:21:33 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/sysUtils/psHash.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sysUtils/psHash.c
r1371 r1375 9 9 * @author Robert Lupton, Princeton University 10 10 * @author George Gusciora, MHPCC 11 * 12 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-08-0 2 22:31:02$11 * 12 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-08-04 01:21:33 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 38 38 table: a hash table 39 39 Return; 40 The linked list 40 The linked list 41 41 *****************************************************************************/ 42 42 psList *psHashKeyList( psHash *table ) … … 114 114 /****************************************************************************** 115 115 hashBucketFree(bucket): This procedure deallocates the specified 116 hash bucket. 116 hash bucket. 117 117 Inputs: 118 118 bucket: the hash bucket to be freed. … … 144 144 The new hash table. 145 145 *****************************************************************************/ 146 psHash *psHashAlloc( int nbucket ) // initial number of buckets146 psHash *psHashAlloc( int nbucket ) // initial number of buckets 147 147 { 148 148 int i = 0; // loop index variable … … 181 181 static void hashFree( psHash *table ) 182 182 { 183 psHashBucket * tmp = NULL; // Used to step through linked list.184 psHashBucket *ptr = NULL; // Used to step through linked list.185 183 int i = 0; // Loop index variable. 186 184 … … 191 189 // Loop through each bucket in the hash table. If that bucket is not 192 190 // NULL, then free the bucket via a function call to hashBucketFree(); 193 194 191 for ( i = 0; i < table->nbucket; i++ ) { 195 // A bucket is composed of a linked list of buckets. We use the 196 // "tmp" and "ptr" pointers to step through that list and free each 197 // non-NULL bucket. 198 192 193 // A bucket is composed of a linked list of buckets. 199 194 if ( table->buckets[ i ] != NULL ) { 200 ptr = table->buckets[ i ]; 201 while ( ptr != NULL ) { 202 tmp = ptr->next; 203 psFree( ptr ); 204 ptr = tmp; 205 } 195 psFree( table->buckets[ i ] ); 206 196 } 207 197 } … … 359 349 itemFree: a function pointer 360 350 Return: 361 boolean value defining success or failure 351 boolean value defining success or failure 362 352 *****************************************************************************/ 363 353 bool psHashAdd( psHash *table, const char *key, void *data ) … … 387 377 The data associated with that key. 388 378 *****************************************************************************/ 389 void *psHashLookup( psHash *table, // table to lookup key in390 const char *key ) // key to lookup379 void *psHashLookup( psHash *table, // table to lookup key in 380 const char *key ) // key to lookup 391 381 { 392 382 if ( table == NULL ) {
Note:
See TracChangeset
for help on using the changeset viewer.
