[comp.sys.mac.programmer] locking INITs

spector@vx2.GBA.NYU.EDU (David HM Spector) (08/24/88)

Yes, INITs should be locked, especially when you are doing things
that move memory.  The best example of this is in Apple's own
example init in TN14 (I think) [its the one entitled "Stand alone code"]
where they give you a teeny init that beeps.... it works fine on a
plus (as long as you are using the OLD sound manager) but crashes with
an address error on other machines..

You can program the Mac without the TechNotes, but they do come in handy
a lot of the time.  They're also available "for free" on the InterNet
from Sumex-aim.

_DHMS
-------------------------------------------------------------------------------
David HM Spector				New York University
Senior Systems Programmer			Graduate School of Business
Arpa: SPECTOR@GBA.NYU.EDU			Academic Computing Center
UUCP:...!{allegra,rocky,harvard}!cmcl2!spector	90 Trinity Place, Rm C-4
HamRadio: N2BCA      MCIMail: DSpector          New York, New York 10006
AppleLink: D1161     CompuServe: 71260,1410     (212) 285-6080
"What computer puts out work like this?"  "Hire us and we'll tell you."
XYZZYGLORP

bob@eecs.nwu.edu (Bob Hablutzel) (08/24/88)

... Stuff omitted ...

>What's the scoop?  Is the system supposed to lock my INIT before executing
>it, or do I have to do it myself?  If the latter, is it appropriate and
>sufficient just to set the Lock attribute for my INIT resource (i.e. in
>the resource file on disk) or should I write code (RecoverHandle, HLock,
>etc.) to lock myself at run time?  And do I have to unlock myself
>before returning to the system?

In all the INITs I've written I've set the locked bit in the resource
header. I would recommend doing this as the fastest and most code
efficient way of doing things. Don't bother unlocking it - it will
be disposed soon anyhow.

>Please indulge me if these are naive questions; this is my first
>piece of Mac code and I'm finding that all of the books I've seen
>(including I.M.) gloss over a lot of the details.  (Is it silly of
>me to try programming the Mac without the Tech Notes?)

No such thing as naive questions when first writting Mac code :-)

One of the biggest problems in programming on the Mac is that details in
IM do tend to get glossed over (To prevent flames: other details are
covered in great detail). Yes, it is silly to try to program on a Mac
without the Tech Notes. Consider them as important as IM itself (sometimes
more important).

>Kelvin Delbarre, AT&T Bell Labs (UNIX Development), Summit NJ, attunix!kd


Bob Hablutzel, Northwestern University ACNS Development
BOB@NUACC.ACNS.NWU.EDU