DaveLee@cup.portal.com (David Alan Lee) (05/28/91)
When, if ever, should one free the list of XmStrings given to a XmList Widget ? It appears safe to free the data after a call to XtSetValues(), with the XmNitems, and XmNitemCount set. However, if I re-set the values of the widget, should I first get the old list via XtGetValues() and free it? Some trial (and mostly error) has shown that it is not safe to free the list returned from XtGetValues(). However, some rumors from a co-worker claim that the internal list stored in an XmList widget do not get freed when re-setting the list values. Is there any truth to this? The documentation (that I have) says absolutly nothing about this. Please E-mail any reply (or copy thereof) to me at the address in the header. -- Dave Lee Email address: David_Alan_Lee@cup.portal.com or DaveLee@cup.portal.com
meeks@osf.org (W. Scott Meeks) (05/31/91)
>Date: 28 May 91 05:37:59 GMT >From: portal!cup.portal.com!DaveLee@apple.com (David Alan Lee) > >When, if ever, should one free the list of XmStrings given to a >XmList Widget ? > >It appears safe to free the data after a call to XtSetValues(), >with the XmNitems, and XmNitemCount set. However, if I re-set >the values of the widget, should I first get the old list >via XtGetValues() and free it? Some trial (and mostly error) >has shown that it is not safe to free the list returned from >XtGetValues(). However, some rumors from a co-worker claim that >the internal list stored in an XmList widget do not get freed >when re-setting the list values. Is there any truth to this? >The documentation (that I have) says absolutly nothing about this. There's no truth to the rumor at all. XmNitems and XmNselectedItems in an XmList conform to the Xt specs for resource values. That is, XtSetValues causes a copy of the resource to be made so you can free the list. XtGetValues returns the actual data stored in the widget, so you should never modify or free the list. XtSetValues will also cause the previous list to be freed. So in summary, the only time you have to free a list of items given to an XmList widget is when you've made your own list to set one of the resources and you're done with it after calling XtSetValues. Side note: resources of type XmString and String (but NOT XmStringTable like XmNitems) return a copy on XtGetValues, so you do have to XmStringFree or XtFree this value after you are done with it. W. Scott Meeks | Open Software Foundation | Motif: think of it as evolution in action. meeks@osf.org | (617) 621-7229 |