Changeset 873 for trunk/psLib/test/sysUtils/tst_psHash03.c
- Timestamp:
- Jun 4, 2004, 1:44:15 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/sysUtils/tst_psHash03.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/sysUtils/tst_psHash03.c
r862 r873 9 9 #include "psTest.h" 10 10 #include "psHash.h" 11 #include "psMemory.h" 11 12 #define NUM_HASH_TABLE_BUCKETS 100 12 13 int imGlobal = 0; 14 int currentId = 0; 13 15 14 16 typedef struct … … 17 19 } 18 20 ID; 21 22 // NOTE: This is my own little routine I used in debugging a memory 23 // leak. I will take this out of this file later. 24 void printMemBlocks(char *myString) 25 { 26 psMemBlock **memBlocks = NULL; 27 psMemBlock *tmp = NULL; 28 int numBlocks = 0; 29 30 numBlocks = psMemCheckLeaks(currentId, &memBlocks, NULL); 31 printf("******************** %s ********************\n", myString); 32 printf("%d mem blocks\n", psMemCheckLeaks(currentId,NULL,NULL)); 33 printf("%d blocks\n", numBlocks); 34 printf("* "); 35 if (memBlocks != NULL) { 36 for (tmp = *memBlocks; tmp != NULL; tmp = tmp->nextBlock) { 37 printf("%d ", (int) tmp->id); 38 } 39 } 40 printf("*\n"); 41 printf("*************************************************\n"); 42 psFree(memBlocks); 43 } 44 19 45 static ID *IdAlloc(const char *name) 20 46 { 21 ID *id = psAlloc(sizeof(ID)); 47 ID *id = NULL; 48 49 id = psAlloc(sizeof(ID)); 50 22 51 id->name = psStringCopy(name); 23 52 … … 40 69 char *myKeys[] = {"ENTRY00", "ENTRY01", "ENTRY02", "ENTRY03", NULL}; 41 70 char *myData[] = {"IDA", "IDB", "IDC", "IDD", NULL}; 42 int currentId = psMemGetId();43 71 int memLeaks = 0; 72 73 currentId = psMemGetId(); 44 74 45 75 printPositiveTestHeader(stdout, … … 48 78 49 79 myHashTable = psHashAlloc(NUM_HASH_TABLE_BUCKETS); 80 50 81 i = 0; 51 82 while (myKeys[i] != NULL) { … … 54 85 i++; 55 86 } 56 57 87 58 88 i = 0; … … 66 96 } 67 97 68 69 98 i = 0; 70 99 while (myKeys[i] != NULL) { 71 id = psHashRemove(myHashTable, myKeys[i]); 100 id = psHashRemove(myHashTable, myKeys[i], (void (*)(void *))IdFree); 101 IdFree(id); 72 102 id = psHashLookup(myHashTable, myKeys[i]); 73 103 if (id != NULL) { … … 78 108 } 79 109 80 81 110 printFooter(stdout, 82 111 "psHash functions", … … 84 113 testStatus); 85 114 86 memLeaks = psMemCheckLeaks(currentId,NULL,NULL);87 printf("HMMM: %d memory leaks. Callin psHashFree()\n", memLeaks);88 115 psHashFree(myHashTable, (void (*)(void *))IdFree); 89 116 memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
Note:
See TracChangeset
for help on using the changeset viewer.
