[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

2696.0. "Allocation of compound strings returned by GET_VALUES" by QUARK::LIONEL (Free advice is worth every cent) Tue May 01 1990 17:06

If I call DWT$GET_VALUES to ask for the label of a widget (using DWT$C_NLABEL),
is the value given to me that of a copy of the label's compound string (which
I can then later free) or is it simply a pointer to the toolkit's string
that I should not modify or free?  And has this changed between DECwindows
V1 and V2?

			Steve
T.RTitleUserPersonal
Name
DateLines
2696.1Don't modify or free itLEOVAX::TREGGIARITue May 01 1990 17:5319
> If I call DWT$GET_VALUES to ask for the label of a widget (using DWT$C_NLABEL),
> is the value given to me that of a copy of the label's compound string (which
> I can then later free) or is it simply a pointer to the toolkit's string
> that I should not modify or free?  

It is a pointer to a compound string that you should not modify or free.
In fact, if you need the value for any length of time you should call
DwtCStrcpy to make a copy.

> And has this changed between DECwindows V1 and V2?

The fact that you shouldn't modify or free it hasn't changed.  How the
toolkit *gets* the value that you get back did change.  V1 used to
always hang on to the compound string.  V2 only hangs on to an internal
format and regenerates the compound string on the call to XtSetValues.
The toolkit frees this regenerated string when the string changes, or
the widget is deleted.  This change saved lots of memory.

Leo
2696.2QUARK::LIONELFree advice is worth every centTue May 01 1990 23:268
    Thanks, Leo.  I will make the requisite changes to DECBURGER (and
    comment them profusely!)
    
    May I suggest that there be some clear and obvious documentation about
    what one can and cannot do with values returned by GET_VALUES?  (Or
    if there is, please point me to it!)
    
    				Steve
2696.3Not in writing, but...DECWIN::KLEINWed May 02 1990 15:3711
It is my understanding that the rule is very simple.  The application should
never free anything returned by XtGetValues.  I can't remember where I read
this, if anywhere, but it is the guideline under which (most?) widget writers
operate.

This rule does not necessarily apply to "special" routines, like
DwtSTextGetString, etc, which are individually documented.  The
documentation for each of these routines should (must) indicate
the required disposition of the returned memory.

-steve-