[comp.sys.mac.programmer] init.driver.resource question

tracyn@dgp.toronto.edu (Tracy Narine) (12/16/90)

I am writing a driver that has resources.  The driver is being loaded by
an init.  In my init I renumber all of the resources and then release them
so the new info is stored.  When my driver is called though, the resources
don't seem to be there.  They method I have taken is to OpenResFile of the
init in the driver.  I think this should give the driver the resources
 it needs but this is not happening because my driver keeps on crashing.
Can some please suggest what I might be doing wrong.

tracy 

davoli@natinst.com (Russell Davoli) (12/17/90)

In article <1990Dec15.225015.8462@jarvis.csri.toronto.edu>, tracyn@dgp.toronto.edu (Tracy Narine) writes:
> 
> I am writing a driver that has resources.  The driver is being loaded by
> an init.  In my init I renumber all of the resources and then release them
> so the new info is stored.  When my driver is called though, the resources
> don't seem to be there.  They method I have taken is to OpenResFile of the
> init in the driver.  I think this should give the driver the resources
>  it needs but this is not happening because my driver keeps on crashing.
> Can some please suggest what I might be doing wrong.
> 
> tracy 

When loading your driver at init time, you ought to detach the driver
resource at least.  I think you want to renumber everything then load it
all into memory and detach all the resources.  You need to detach because
as soon as the init finishes executing, its resource file is closed and
the resource manager releases all the resources.

From reading your post, I'm not sure it helps, but I hope it does.

Russell Davoli
National Instruments Corp.

oster@well.sf.ca.us (David Phillip Oster) (12/17/90)

In article <1990Dec15.225015.8462@jarvis.csri.toronto.edu> tracyn@dgp.toronto.edu (Tracy Narine) writes:
>I am writing a driver that has resources.  The driver is being loaded by
>an init.  In my init I renumber all of the resources and then release them
>so the new info is stored.  When my driver is called though, the resources
>don't seem to be there.  They method I have taken is to OpenResFile of the
>init in the driver.  I think this should give the driver the resources
> it needs but this is not happening because my driver keeps on crashing.

When the INIT returns, all attached resource get discarded, so be sure your
INIT does DetachResource after caching the handle in the driver's data
space so the driver can find it. Also, the INIT runs in the application
heap, and the application heap is destroyed and re-used as soon as the iNIT 
returns. If you turn on the systemHeap bit on your resources,  they will go
in the system heap and stick around. Check the Control Panel chapter of
Inside Mac Vol4 for information on the sysz resource. This resource tells
the system to expand the system heap if necessary, before your INIT runs, so
it will find enough space, when it actually runs. Good luck.
-- 
-- David Phillip Oster - At least the government doesn't make death worse.
-- oster@well.sf.ca.us = {backbone}!well!oster