IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 177


Ignore:
Timestamp:
Mar 9, 2004, 3:04:39 PM (22 years ago)
Author:
rhl
Message:

1/ Added psTraceReset() to reset the trace facility to startup, and free memory
2/ Changed New/Del to Alloc/Free

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/pslib/src/Utils/trace.c

    r141 r177  
    4141/*****************************************************************************/
    4242
    43 static Component *componentNew(const char *name,
    44                               int level)
     43static Component *componentAlloc(const char *name,
     44                                int level)
    4545{
    4646    Component *comp = psAlloc(sizeof(Component));
     
    5454}
    5555
    56 static void componentDel(Component *comp)
     56static void componentFree(Component *comp)
    5757{
    5858    if (comp == NULL) { return; }
    5959
    6060    if (comp->subcomp != NULL) {
    61         for (int i = 0; comp->subcomp[i] != NULL; i++) {
    62             componentDel(comp->subcomp[i]);
     61        for (int i = 0; i < comp->n; i++) {
     62            componentFree(comp->subcomp[i]);
    6363        }
    6464        psFree(comp->subcomp);
    6565    }
    6666
     67    psFree((char *)comp->name);
    6768    psFree(comp);
    6869}
     
    7677static void initTrace(void) {
    7778    if (croot == NULL) {
    78         croot = componentNew("", UNKNOWN_LEVEL);
    79     }
     79        croot = componentAlloc("", UNKNOWN_LEVEL);
     80    }
     81}
     82
     83/*****************************************************************************/
     84/*
     85 * Free the trace tree information
     86 */
     87void psTraceReset(void)
     88{
     89    componentFree(croot);
     90    croot = NULL;
    8091}
    8192
     
    128139    }
    129140
    130     Component *fcpt0 = componentNew(cpt0, UNKNOWN_LEVEL);
     141    Component *fcpt0 = componentAlloc(cpt0, UNKNOWN_LEVEL);
    131142    int i;
    132143    for (i = 0; i < comp->n; i++) {
     
    295306int main(void)
    296307{
     308    psSetLogFormat("NM");               // suppress some of the psLogMsg verbosity
     309   
    297310#if 0
    298311    psSetTraceLevel("", 10);
     
    322335    psTrace("aaa.bbb.eee", 2, "aaa.bbb.eee\n");
    323336
     337    psTraceReset();
     338    fprintf(stderr,"Checking for memory leaks:\n");
     339    psMemCheckLeaks(0, NULL, stderr);
     340   
     341
    324342    return 0;
    325343}
Note: See TracChangeset for help on using the changeset viewer.