Ignore:
Timestamp:
May 24, 2001, 5:21:06 PM (24 years ago)
Author:
umoeller
Message:

Misc updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/linklist.c

    r71 r74  
    311311 *      This must only be used with heap lists created
    312312 *      with lstCreate.
    313  */
    314 
    315 BOOL lstFree(PLINKLIST pList)
     313 *
     314 *      This uses a pointer to a PLINKLIST so that
     315 *      the pointer is automatically reset to NULL
     316 *      by this function AND to avoid confusion
     317 *      with lstClear.
     318 *
     319 *@@changed V0.9.12 (2001-05-24) [umoeller]: changed prototype to use pointer to pointer
     320 */
     321
     322BOOL lstFree(PLINKLIST *ppList)
    316323{
    317324    BOOL brc = FALSE;
    318 
    319     if (lstClear(pList))        // this checks for list integrity
    320     {
    321         // unset magic word; the pList pointer
    322         // will point to invalid memory after
    323         // freeing the list, and subsequent
    324         // integrity checks must fail
    325         pList->ulMagic = 0;
    326         free(pList);
    327 
    328         brc = TRUE;
    329     }
     325    PLINKLIST p;
     326
     327    if (    (ppList)
     328         && (p = *ppList)
     329       )
     330        if (lstClear(p))        // this checks for list integrity
     331        {
     332            // unset magic word; the pList pointer
     333            // will point to invalid memory after
     334            // freeing the list, and subsequent
     335            // integrity checks must fail
     336            p->ulMagic = 0;
     337            free(p);
     338
     339            *ppList = NULL;
     340
     341            brc = TRUE;
     342        }
    330343
    331344    return (brc);
Note: See TracChangeset for help on using the changeset viewer.