From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  8-DEC-1989 13:50
To:	MRGATE::"ARISIA::EVERHART"
Subj:	Minor PerfMeter fix (memory leak problem)

Received: From CRASH.CS.UMASS.EDU by GIZMO.SRI.COM with TCP; Fri,  8 DEC 89 08:50:41 PDT
Received: from vax3.cs.umass.edu by crash.cs.umass.edu (5.61/Ultrix2.0-B)
	id AA20897; Fri, 8 Dec 89 11:47:33 -0500
Message-Id: <8912081647.AA20897@crash.cs.umass.edu>
Date: Fri, 8 Dec 89 11:45 EST
From: "From the screen of Deneva...  08-Dec-1989 1145" <HELLER@cs.umass.EDU>
Subject: Minor PerfMeter fix (memory leak problem)
To: info-vax@kl.sri.COM
X-Vms-To: coins::in%"info-vax@kl.sri.com"

I think I have found the "leak".  The documentation is not very clear on just 
what really happens with a Set Values call when you set the Label attribute on a 
label widget.  It seems that the compound string is copied into the label 
widget.  My code was calling DwtLatin1String() and never freeing up the memory 
allocated (i.e. not calling XtFree()) - I was thinking that only the pointer was 
copied and that any old pointer was being freed up.  The fix is as follows:

First insert this function:


/*
 * Simplified SET VALUE routine to use only when changing a label widget's
 * label string.  Does a Latin1 String and frees the compound string after
 * setting label value
 */

static void set_label(w, value)
Widget w;
char *value;
    {
    Arg al[1];
    DwtCompString latin_label;


    latin_label = DwtLatin1String(value);
    XtSetArg(al[0], DwtNlabel, latin_label);
    XtSetValues(w, al, 1);
    XtFree(latin_label);
    }

between the definations of set_something() and get_something() and change all of 
the calls to set_something() which look like:

	set_something(some-widget,DwtNlabel,DwtLatin1String(some char*));

to look like:

	set_label(some-widget,some char*);

Most of these are near the end of update() and one is in 
update_disk_name_label().

					Robert


