[comp.windows.x] Is the resource manager weird, or is it just me?

setzer@nssdcs (William Setzer (IDM)) (06/16/89)

I have just finished debugging the resource manager portion of my (first
real) X Window application.  The bug that caused me grief was the following:

The database that I passed to XrmParseCommand was declared inside of a
function (ie. it was type auto).  As I discovered, it didn't contain NULL.
Thus when XrmGetResource was called, it tried to find quarks in all of the
garbage that my variable happened to point to (can anyone say 'bus error'?).
The problem is, XrmDatabase is an opaque data type.  Thus, I _can't_
initialize it (to NULL).  Therefore, I have to declare the variable globally,
and thus take advantage of C's implicit zeroing out of the data.

Now to the questions:
(1)  Can the rm be used (safely) with only local variables?
(2)  Is there a way to initialize XrmDatabase variables to NULL (legally)?
(3)  Did I just miss something?
(4)  Is it a 'bug', a 'feature', or neither?

Any help would be appreciated.  This 'bug' just burns me up.
--
William Setzer
nssdcs.gsfc.nasa.gov

setzer@nssdcs.gsfc.nasa.gov (William Setzer (IDM)) (06/16/89)

I just realized an ambiguity in the phrasing of my questions.  What I would
like to do is use non-static local XrmDatabase variables.  It may just be
a personal peeve, but I do not like relying on implicit variable initialization
to do work.  Thus, declaring a static local variable and relying on it passing
for NULL contents is something that I would like to avoid.  Please add an
implicit "without relying on automatic initialization" to the meanings of all
my questions.  Thank you.
--
William Setzer
nssdcs.gsfc.nasa.gov

swick@ATHENA.MIT.EDU (Ralph R. Swick) (06/16/89)

     Date:  15 Jun 89 23:29:08 GMT
     From:  dftsrv!nssdcs!setzer@AMES.ARC.NASA.GOV  (William Setzer (IDM))

     The problem is, XrmDatabase is an opaque data type.  Thus, I _can't_
     initialize it (to NULL).
      
XrmDatabase is semi-opaque.  It is specified as a pointer to an
undefined structure.  It is therefore legal to assign NULL to
a variable of this type.