Changeset 1295
- Timestamp:
- Jul 23, 2004, 5:31:22 PM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 2 edited
-
src/sysUtils/psHash.c (modified) (4 diffs)
-
test/sysUtils/tst_psHash03.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sysUtils/psHash.c
r1202 r1295 10 10 * @author George Gusciora, MHPCC 11 11 * 12 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-07- 08 22:05:14$12 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-07-24 03:31:06 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 357 357 itemFree: a function pointer 358 358 Return: 359 NONE359 boolean value defining success or failure 360 360 *****************************************************************************/ 361 361 bool psHashAdd(psHash *table, const char *key, void *data) … … 407 407 itemFree: a function pointer 408 408 Return: 409 The data that was associated with that key. 410 *****************************************************************************/ 411 void *psHashRemove(psHash *table, const char *key) 412 { 409 boolean value defining success or failure 410 *****************************************************************************/ 411 bool psHashRemove(psHash *table, const char *key) 412 { 413 void *data = NULL; 414 bool retVal = false; 415 413 416 if (table == NULL) { 414 417 psAbort(__func__, "psHashRemove() called with NULL hash table."); … … 418 421 } 419 422 420 return doHashWork(table, key, NULL, 1); 421 } 423 data = doHashWork(table, key, NULL, 1); 424 if ( data != NULL) { 425 psFree(data); 426 retVal = true; 427 } else { 428 retVal = false; 429 } 430 return retVal; 431 } -
trunk/psLib/test/sysUtils/tst_psHash03.c
r1201 r1295 68 68 int i = 0; 69 69 int TotalKeys = 0; 70 bool retVal = false; 70 71 ID *id = NULL; 71 72 char *myKeys[] = {"ENTRY00", "ENTRY01", "ENTRY02", "ENTRY03", NULL}; … … 101 102 i = 0; 102 103 while (myKeys[i] != NULL) { 103 id = psHashRemove(myHashTable, myKeys[i]);104 104 // The psHashRemove() procedure removes the entry from the hash 105 // table, but does not delete the data. The following is necessary 106 // to delete the data as well (which is returned from the call). 107 psFree(id); 105 // table and deletes the data. 106 retVal = psHashRemove(myHashTable, myKeys[i]); 107 if (!retVal) { 108 fprintf(stderr,"%s: Hash table entry not removed.\n",__func__); 109 } 108 110 id = psHashLookup(myHashTable, myKeys[i]); 109 111 if (id != NULL) { … … 124 126 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); 125 127 } 126 psMemCheckCorruption( 1);128 psMemCheckCorruption(true); 127 129 128 130 return (!testStatus); 129 131 } 132
Note:
See TracChangeset
for help on using the changeset viewer.
