devsop%ra%netvax@CCC.NMFECC.GOV (Pothier Steve) (02/27/90)
The X Toolkit Intrinsics manual (X11R3) says "These functions [XtMalloc, XtCalloc, XtRealloc] are completely compatible with their C language runtime counterparts ..." However, the Xt versions don't seem to return if space can't be allocated. Does this mean one should use the Xt alloc functions only when the memory they grab is strictly necessary to continue with client execution? Should we use regular C alloc functions when there is the possibility of continueing from a failed alloc? advTHANKSance, ============================================================================== Steve Pothier pothiers%tuva.sainet@nmfecc.arpa Science Applications International Tucson, AZ 602-748-7400 ==============================================================================
rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (03/01/90)
The X Toolkit Intrinsics manual (X11R3) says "These functions [XtMalloc, XtCalloc, XtRealloc] are completely compatible with their C language runtime counterparts ..." But it explicitly goes on to say "with the following added functionality" and explains that out-of-memory produces an error, and the description of XtError explicitly says that it invokes XtErrorMsg in this case. Does this mean one should use the Xt alloc functions only when the memory they grab is strictly necessary to continue with client execution? Yes. Should we use regular C alloc functions when there is the possibility of continueing from a failed alloc? Sure.
ben@hpcvlx.cv.hp.com (Benjamin Ellsworth) (03/02/90)
> However, the Xt versions don't seem to return if space can't be > allocated. Huh? Look at Alloc.c in the Xt source and help me understand why they wouldn't return, and why it would be Xt's fault. > Steve Pothier ----------------------------------------------------------------------- Benjamin Ellsworth | ben@cv.hp.com | INTERNET Hewlett-Packard Company | {backbone}!hplabs!hp-pcd!ben | UUCP 1000 N.E. Circle | (USA) (503) 750-4980 | FAX Corvallis, OR 97330 | (USA) (503) 757-2000 | VOICE ----------------------------------------------------------------------- All relevant disclaimers apply. -----------------------------------------------------------------------
ben@hpcvlx.cv.hp.com (Benjamin Ellsworth) (03/02/90)
I wrote: >> However, the Xt versions don't seem to return if space can't be >> allocated. > > Huh? Look at Alloc.c in the Xt source and help me understand why they > wouldn't return, and why it would be Xt's fault. > >> Steve Pothier I had assumed that what was meant by "don't seem to return" was a prgram hang. Mea culpa. It is true that in an error condition XtError is called and XtError will not return (exit is called). This should be accompanied by and error message. (The error message was not mentioned so I thought we were talking about a different problem.) If you really want to continue after a malloc error, you could install your own XtError handler. Some pitfalls are, not easily determining who called the XtError (it is called by more than XtMalloc), and how to continue --what if it is an Xt intrinsic call which runs out of memory, like XtCreateWidget? --- Ben
asente@decwrl.dec.com (Paul Asente) (03/02/90)
In article <9002271554.AA12993@ra.> devsop%ra%netvax@CCC.NMFECC.GOV (Pothier Steve) writes: >However, the Xt versions don't seem to return if space can't be >allocated. Does this mean one should use the Xt alloc functions only >when the memory they grab is strictly necessary to continue with >client execution? Should we use regular C alloc functions when there >is the possibility of continueing from a failed alloc? Yes. However, most applications react to a failed malloc (if they bother to react to it at all) by issuing an error message, so XtMalloc does this automatically as a convenience to the programmer. If you can recover from a failed malloc, by all means use malloc. -paul asente asente@decwrl.dec.com decwrl!asente
kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (03/02/90)
> However, the Xt versions don't seem to return if space can't be > allocated. Only when using the Default Error Handler. You can register and error handler that alerts you to memory allocation errors, and attempt to recover if you want to. This should allow use of the Xt Allocation functions. Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213