Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!ispd-newsserver!ism.isc.com!ico!auto-trol!marbru From: marbru@auto-trol.com (Martin Brunecky) Newsgroups: comp.windows.x Subject: Re: more on XmString problem Keywords: Motif 1.1, XmStringCreateLtoR, XmStringGetLtoR, UIL Message-ID: <1991Apr26.164038.29255@auto-trol.com> Date: 26 Apr 91 16:40:38 GMT References: <95655@lll-winken.LLNL.GOV> <8861@gollum.twg.com> Sender: news@auto-trol.com Organization: Auto-trol Technology Corporation Lines: 26 Nntp-Posting-Host: auto-trol In article <8861@gollum.twg.com> david@twg.com (David S. Herron) writes: >>char* get_label(Widget id) >> .... >> XtSetArg(wargs[0], XmNlabelString, &label_str); >> XtGetValues(id, wargs, 1); >> >> /* Pull the character string out of the XmString */ >> XmStringGetLtoR(label_str, XmSTRING_DEFAULT_CHARSET, &label); >> >> /* Free the Xm string */ >> XmStringFree(label_str); ^^^^^^^^^^^^^^^^^^^^^^^ Yes, this is one of the "things" Motif does to you - you'w got to read the fine print in the Motif docs when and which resources returned by XtGetValues you have to FREE (otherwise you have a nice memory leak). You can probably imagine what happens if you extend this "rule" to some other case and do "free" on a label returned from Athena widget -). Is it RIGHT ??? -- =*= Opinions presented here are solely of my own and not those of Auto-trol =*= Martin Brunecky marbru%auto-trol@sunpeaks.central.sun.com (303) 252-2499 (better avoid: marbru@auto-trol.COM ) Auto-trol Technology Corp. 12500 North Washington St., Denver, CO 80241-2404