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

    r1022 r1073  
    1919}
    2020ID;
     21static void IdFree(ID *id);
     22
    2123static ID *IdAlloc(const char *name)
    2224{
    2325    ID *id = psAlloc(sizeof(ID));
     26    p_psMemSetDeallocator(id,(psFreeFcn)IdFree);
    2427    id->name = psStringCopy(name);
    2528
     
    3134    imGlobal++;
    3235    psFree(id->name);
    33     psFree(id);
    3436}
    3537
     
    5254    i = 0;
    5355    while (myKeys[i] != NULL) {
    54         psHashInsert(myHashTable, myKeys[i], IdAlloc(myData[i]),
    55                      (void (*)(void *))IdFree);
     56        id = IdAlloc(myData[i]);
     57        psHashInsert(myHashTable, myKeys[i], id);
     58        psFree(id);
    5659        i++;
    5760    }
     
    7881
    7982    //    psHashFree(myHashTable, NULL);
    80     psHashFree(myHashTable, (void (*)(void *))IdFree);
     83    psFree(myHashTable);
    8184
    8285    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
Note: See TracChangeset for help on using the changeset viewer.