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_psHash04.c

    r929 r1073  
    1414}
    1515ID;
     16static void IdFree(ID *id);
     17
    1618static ID *IdAlloc(const char *name)
    1719{
    1820    ID *id = psAlloc(sizeof(ID));
     21    p_psMemSetDeallocator(id,(psFreeFcn)IdFree);
     22
    1923    id->name = psStringCopy(name);
    2024
     
    2630    imGlobal++;
    2731    psFree(id->name);
    28     psFree(id);
    2932}
    3033
     
    4043    psList *myLinkList = NULL;
    4144    psListElem *tmp = NULL;
     45    ID* id = NULL;
    4246
    4347    printPositiveTestHeader(stdout,
     
    4852    i = 0;
    4953    while (myKeys[i] != NULL) {
    50         psHashInsert(myHashTable, myKeys[i], IdAlloc(myData[i]),
    51                      (void (*)(void *))IdFree);
     54        id = IdAlloc(myData[i]);
     55        psHashInsert(myHashTable, myKeys[i], id);
     56        psFree(id);
    5257        i++;
    5358    }
     
    5964    }
    6065
    61     psListFree(myLinkList, NULL);
     66    psFree(myLinkList);
    6267
    6368    printFooter(stdout,
     
    6671                testStatus);
    6772
    68     psHashFree(myHashTable, (void (*)(void *))IdFree);
     73    psFree(myHashTable);
    6974
    70     memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
     75    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
    7176    if (0 != memLeaks) {
    7277        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
Note: See TracChangeset for help on using the changeset viewer.