[comp.windows.x] Need opinions re: BadAlloc

gjw@ANDREAS.WR.USGS.GOV (Gregory J. Woodhouse) (12/22/90)

I'm now writing the code which sets the various properties WM_COMMAND,
WM_CLIENT_MACHINE, etc. required by the ICCCM.  I doubt a failure to
intern these atoms is likely, but am not at all sure how to procede if
trying to write to them produces a BadAlloc.  Is it preferable to
simply quit, not write to the properties (Here, I would have to trap the
error), or try to write some minimal set of properties?  In the latter
case, which ones?  Is there another course of action I'm missing?
A related question is: How likely are these errors to occur?  And again,
if I get a BadAlloc, what would have to happern for a later call to
XChangeProperty to succeed?

Pardon my naivete but I've never tried to write an ICCCM compliant applic-
ation before.

-----------------------------------------------------------------------------
Gregory Woodhouse          |We know that the center of the earth
gjw@andreas.wr.usgs.gov    |is a fiery molten mass...but it's not
(415) 329-4694 (office)    |good to dwell on it.
(415) 325-7802 (home)      |
U.S. Geological Survey / 345 Middlefield Rd. MS 977 / Menlo Park, CA 94025
-----------------------------------------------------------------------------

mouse@LARRY.MCRCIM.MCGILL.EDU (12/22/90)

> I'm now writing the code which sets the various properties
> WM_COMMAND, WM_CLIENT_MACHINE, etc. required by the ICCCM.  I doubt a
> failure to intern these atoms is likely, but am not at all sure how
> to procede if trying to write to them produces a BadAlloc.

I would not fault an application for simply dying if that happens.
Besides, if the server can't even intern an atom, it is probably going
to be failing right and left when you try to create the rest of your
window tree, pixmaps, and whatnot.

> A related question is: How likely are these errors to occur?

I wouldn't even consider the possibility.  I'd just let the default
error handler deal with the situation.  A server that short of memory
is pretty nearly useless anyway.

> And again, if I get a BadAlloc, what would have to happern for a
> later call to XChangeProperty to succeed?

Something would have to free up some memory in the server...for
example, shutting down an application or two should do it.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

stripes@eng.umd.edu (Joshua Osborne) (12/27/90)

In article <9012220228.AA10299@Larry.McRCIM.McGill.EDU>, mouse@LARRY.MCRCIM.MCGILL.EDU writes:
> > I'm now writing the code which sets the various properties
> > WM_COMMAND, WM_CLIENT_MACHINE, etc. required by the ICCCM.  I doubt a
> > failure to intern these atoms is likely, but am not at all sure how
> > to procede if trying to write to them produces a BadAlloc.
> 
> I would not fault an application for simply dying if that happens.
> Besides, if the server can't even intern an atom, it is probably going
> to be failing right and left when you try to create the rest of your
> window tree, pixmaps, and whatnot.

It is possable that a server would have a diffrent memmory area for propertys
(the MIT server doesn't), for example storing all props in a 64K segment :-(
With the growing number of X terminals, and X servers for 80x86 boxes these
things are more likely.  The best thing is to try to issue an error message
an go on.  However I too would not fault an application that simply allows
the normal error handler to print a message and abort the application.

There is also the possability that WM_COMMAND is verry large (>32K, or >64K) and
some servers may not support props that large (for the same reasons as above),
or that there isn't that much contigus memmory available, but plenty of fragments
are available (an Xterminal vender may have assumed that best-fit memmory
allocation shoul be used), the application may be able to run normally if it
ignores the WM_COMMAND failure...

[...]
-- 
           stripes@eng.umd.edu          "Security for Unix is like
      Josh_Osborne@Real_World,The          Multitasking for MS-DOS"
      "The dyslexic porgramer"                  - Kevin Lockwood
"Don't over-comment"     - p151 The Elements of Programming Style 2nd Edition
                                   Kernighan and Plauger