20.3.2 Compound String Retrieval
You can retrieve a compound string from a Motif widget using XtVaGetValues(). However, the way
XtVaGetValues() is used for compound string resources is different than how it is used for most other resources.
The value returned by XtVaGetValues() for a compound string resource is a copy of the internal data, so the
compound string must be freed by the application, as shown in the following code fragment:
XmString str;
extern Widget pushbutton;
char *text;
XtVaGetValues (pushbutton, XmNlabelString, &str, NULL);
...
/* do whatever you want with the compound string */
...
XmStringFree (str); /* must free compound strings from GetValues */
To avoid memory leaks in your application, you must remember to free any compound strings that you retrieve from a
widget using XtVaGetValues().
20.3.3 Compound String Conversion
If the Motif routines described in the previous section are inadequate for your needs, you can convert compound
strings back into C strings and manipulate them using the conventional C functions. This process can be simple or
complicated depending on the complexity of the compound string to be converted. If the compound string only has
one tag associated with it and has a left−to−right orientation, the process is quite simple. In this case, which is quite
common, you can use the following function to make the conversion:
Boolean
XmStringGetLtoR(string, tag, text)
XmString string;
XmStringCharSet tag;
char **text;
XmStringGetLtoR() takes a compound string ...