IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 23, 2004, 1:00:17 PM (22 years ago)
Author:
desonia
Message:

Changed the means of deallocation of memory. ps_Alloc now registers an optional free function to handle any additional processing of a memory object.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/sysUtils/tst_psHash03.c

    r1022 r1073  
    1919}
    2020ID;
     21static void IdFree(ID *id);
    2122
    2223// NOTE: This is my own little routine I used in debugging a memory
     
    4849
    4950    id = psAlloc(sizeof(ID));
     51    p_psMemSetDeallocator(id,(psFreeFcn)IdFree);
    5052
    5153    id->name = psStringCopy(name);
     
    5860    imGlobal++;
    5961    psFree(id->name);
    60     psFree(id);
    6162}
    6263
     
    8283    i = 0;
    8384    while (myKeys[i] != NULL) {
    84         psHashInsert(myHashTable, myKeys[i], IdAlloc(myData[i]),
    85                      (void (*)(void *))IdFree);
     85        psHashInsert(myHashTable, myKeys[i], IdAlloc(myData[i]));
    8686        i++;
    8787    }
     
    101101    i = 0;
    102102    while (myKeys[i] != NULL) {
    103         id = psHashRemove(myHashTable, myKeys[i], (void (*)(void *))IdFree);
     103        id = psHashRemove(myHashTable, myKeys[i]);
    104104        // The psHashRemove() procedure removes the entry from the hash
    105105        // table, but does not delete the data.  The following is necessary
    106106        // to delete the data as well (which is returned from the call).
    107         IdFree(id);
     107        psFree(id);
    108108        id = psHashLookup(myHashTable, myKeys[i]);
    109109        if (id != NULL) {
     
    119119                testStatus);
    120120
    121     psHashFree(myHashTable, (void (*)(void *))IdFree);
    122     memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
     121    psFree(myHashTable);
     122    memLeaks = psMemCheckLeaks(currentId,NULL,stdout);
    123123    if (0 != memLeaks) {
    124124        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
Note: See TracChangeset for help on using the changeset viewer.