[comp.sys.mac.programmer] cdev woes; nil handles?

essam@gagme.chi.il.us (Essam Khairullah) (04/03/91)

I had written an INIT/cdev combination that will pop up a dialog at times
which could be set in the Control Panel.  It was working just fine and
dandy but I allocated memory for various resources (mostly PICTs) on the
fly.  I decided that that wasn't what Apple would want since a cdev should
allocate all of the memory it needs when it gets the initDev message.

So I tacked on storage for my PICTs to my cdev's data structure and read
them all in on receiveing the initDev message.  But now my cdev crashes
with a Bus Error when I close the cdev and sometime during other times.  I've
gone all through the cdev with a fine-toothed comb and can't tell what's
going on.  My about box gets a string from the resource fork of the cdev
but it only gets the proper string the second time I display the about
box; the first time through it gets only garbage.  I'm calling ResError
just about every other line of my cdev, but I never get a ResError.

I'm writing this cdev using Think C 4.0 on a Mac II, using System 6.0.7.
I'm using Think's cdev class only for the cdev proper, everything else
is plain C.  I was trying to use the cdev runner project, but it would
freeze the machine after opening my cdev.  The number/variety of INITs
on my machine doesn't seem to make any difference.

Does anyone have any ideas what could be going on?  I lock my main data
structure in memory and call HNoPurge for just about everything else!!

--Thanks in advance,
--Essam

-- 

	Essam Badi' Abu Khalil Khairullah Al-Madani Al-Hussain
			  essam@gagme.chi.il.us
	   I don't got no fancy signature, but it is long!