Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!sun-barr!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!think.com!mintaka!spdcc!tauxersvilli!alphalpha!nazgul From: nazgul@alphalpha.com (Kee Hinckley) Newsgroups: comp.windows.x Subject: Re: XmString Question Message-ID: <1990Dec5.020710.12550@alphalpha.com> Date: 5 Dec 90 02:07:10 GMT References: <502@zok.UUCP> <917@stewart.UUCP> Organization: asi Lines: 32 In article <917@stewart.UUCP> jerry@stewart.UUCP (Jerry Shekhel) writes: >This seems to work. My question: does 'str' have to be deallocated at this >point? That is, did XtGetValues() create an entire new instance of the >XmString? Does XtSetValues() create an internal instance of the XmString, >or does it just set up pointers to 'str'? Please help if you can. If you do a SetValues you definitely should deallocate the string afterwards. The GetValues is a little less consistant. The release notes for 1.1 state that everything is copied except XmNdialogTitle, XmNdirectory, XmNnoMatchString, XmNlabelString (RowColumn only) and XmNtitleString (in Scale). Presumbably those will be fixed at some later date. Also in XmList XmNitems and XmNselectedItems, which are arrays of XmStrings are not copied (and you wouldn't want them to be). I'm pretty convinced that the only right way to do this is to reference count XmStrings. Then you always copy what is handed to you if you want it, but all copy does is increment the reference count. Then nothing is copied in the GetValues, you just get a pointer to the real thing. But in the meantime the above stands. If you're stuck with 1.0 I think the situation is a bit more mixed up. You still want to do a free after setting values, but I'm not sure about getting values. -kee -- Alphalpha Software, Inc. | motif-request@alphalpha.com nazgul@alphalpha.com |----------------------------------- 617/646-7703 (voice/fax) | Proline BBS: 617/641-3722 I'm not sure which upsets me more; that people are so unwilling to accept responsibility for their own actions, or that they are so eager to regulate everyone else's.