[comp.windows.x.motif] When to free XmStrings?

gaf@uucs1.UUCP (gaf) (12/06/90)

One of the things about Motif which has never been clear to me is under what
conditions I'm expected to free memory which a library function has allocated.

Should I free the result of an XmStringCreateLtoR() or an XmStringGetLtoR()?
Does it matter whether I use free() or XmStringFree()?
When I call XtSetValues() to set or change some XmString resource, can I
free the XmString immediately afterward (i.e. do the library functions always
make a copy of what I pass) or hang onto it forever?

And, finally, why does nobody offer Motif classes at reasonable prices :-).
(A few thousand a head plus T&L is too much for little companies like us)
-- 
Guy Finney					It's that feeling of deja-vu
UUCS inc.   Phoenix, Az				all over again.
ncar!noao!asuvax!hrc!uucs1!gaf	sun!sunburn!gtx!uucs1!gaf

kaleb@thyme.jpl.nasa.gov (Kaleb Keithley ) (12/07/90)

In article <361@uucs1.UUCP> gaf@uucs1.UUCP () writes:
>
>One of the things about Motif which has never been clear to me is under what
>conditions I'm expected to free memory which a library function has allocated.
>
>Should I free the result of an XmStringCreateLtoR() or an XmStringGetLtoR()?

In general, yes.  The release notes identify the exceptions to this rule,
if you could call it a rule.

>Does it matter whether I use free() or XmStringFree()?

In 1.1, XmStringFree() just calls XtFree().  XtFree() checks for null ptr
and calls XFree(), XFree() calls free(). 

>When I call XtSetValues() to set or change some XmString resource, can I
>free the XmString immediately afterward (i.e. do the library functions always
>make a copy of what I pass) or hang onto it forever?

We do.

>And, finally, why does nobody offer Motif classes at reasonable prices :-).
>(A few thousand a head plus T&L is too much for little companies like us)

We paid $1000/person (at least that's what was charged to our project) 
to have OSF teach Motif programming.  Price included the Prentice Hall 
OSF/Motif documentation set.  The course was well done, the instructor
first rate.

-- 
Kaleb Keithley                      Jet Propulsion Labs
kaleb@thyme.jpl.nasa.gov

You can please all of the people some of the time,