Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: More Macintosh Toolbox /
Chapter 1 - Resource Manager / Resource Manager Reference
Resource Manager Routines / Writing to Resource Forks


SetResPurge

You can use the SetResPurge procedure to have the Memory Manager pass the handle of a resource to the Resource Manager before purging the data specified by that handle.

PROCEDURE SetResPurge (install: Boolean);
install
A Boolean value that specifies whether the Memory Manager checks with the Resource Manager before purging a resource handle.
DESCRIPTION
Specify TRUE in the install parameter to make the Memory Manager pass the handle for a resource to the Resource Manager before purging the resource data to which the handle points. The Resource Manager determines whether the handle points to a resource in the application heap. It also checks if the resource's resChanged attribute is set to 1. If these two conditions are met, the Resource Manager calls the WriteResource procedure to write the resource's resource data to the resource fork before returning control to the Memory Manager.

Specify FALSE in the install parameter to restore the normal state, so that the Memory Manager purges resource data when it needs to without calling the Resource Manager.

You can use SetResPurge in applications that modify purgeable resources. You should also take precautions in such applications to ensure that the resource won't be purged while you're changing it.

SPECIAL CONSIDERATIONS
If you call SetResPurge with the install parameter set to TRUE and then call the Memory Manager procedure MoveHHi to move a handle to a resource, the Resource Manager calls the WriteResource procedure to write the resource data to disk even if the data has not been changed. To prevent this, call SetResPurge with the install parameter set to FALSE before you call MoveHHi, then call SetResPurge with the install parameter set to TRUE immediately after you call MoveHHi.

Whenever you call SetResPurge with the install parameter set to TRUE, the Resource Manager installs its own purge-warning procedure, overriding any purge-warrning procedure you've specified to the Memory Manager.

SEE ALSO
To check for errors, call the ResError function as described on page 1-47.

For descriptions of the SetResAttrs and WriteResource procedures, see page 1-80 and page 1-88, respectively.

For more information about the Memory Manager procedure MoveHHi, see Inside Macintosh: Memory.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996