Carbon


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
);
Parameter descriptions
initBlock

A pointer to a fragment initialization block specifying information about the fragment.

function result

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.

DISCUSSION

A fragment’s initialization function is executed immediately before the fragment’s 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 fragment’s resource fork (if it has one). You can determine the location of the fragment’s container from the FragmentLocator field of the fragment initialization block whose address is passed to your initialization function.


© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)