![]() |
CFragInitFunction |
||||
Header: | CodeFragments.h | Carbon status: | Supported | |
Defines a fragment initialization function. Your fragment initialization function is executed by the Code Fragment Manager when the fragment is first loaded into memory and prepared for execution.
typedef OSErr(* CFragInitFunction) ( const CFragInitBlock *initBlock );
You would declare your function like this if you were to name it MyCallback:
OSErr MyCFragInitFunction ( const CFragInitBlock *initBlock );
A pointer to a fragment initialization block specifying information about the fragment.
A result code. Your initialization function should return noErr if it executes successfully, and some other result code if it does not. If your initialization function returns any result code other than noErr, the entire load fails and the error fragUserInitProcErr is returned to the code that requested the root load.
A fragments initialization function is executed immediately before the fragments main function (if it has one) is executed. The initialization function is passed a pointer to an initialization block, which contains information about the fragment, such as its location and connection ID. See InitBlock for a description of the fields of the initialization block.
You can use the initialization function to perform any tasks that need to be performed before any of the code or data in the fragment is accessed. For example, you might want to open the fragments resource fork (if it has one). You can determine the location of the fragments container from the FragmentLocator field of the fragment initialization block whose address is passed to your initialization function.
Supported in Carbon.
© 2000 Apple Computer, Inc. (Last Updated 4/14/2000)