home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-10-25 | 1.4 KB | 31 lines | [TEXT/MPS ] |
- ;
- ; DisposeResource - by Greg Marriott
- ;
- ; © 1992, Apple Computer, Inc.
- ;
- ; DisposeResource is a debugging utility made to catch a common programming error:
- ; passing a resource handle to _DisposeHandle.
- ;
- ; The Resource Manager keeps track of in-memory resources by storing their handles
- ; in the resource map. If the block used by the resource is freed without letting the
- ; resource manager know (by calling _ReleaseResource), then the handle reference will
- ; not be removed from the resource map. This can lead to crashes and data loss.
- ;
- ; Future allocations in the heap will likely re-use the master pointer for another
- ; relocatable block. If this happens, then the handle returned to the client will
- ; be the same value as the handle in the resource map. Magically (or sadly), the
- ; handle in the map will now suddenly refer to a random block in the heap. This data
- ; could be written out to the resource file, or trashed if _LoadResource is called on
- ; the “resource” handle.
- ;
- ; DisposeResource will break into the debugger if _DisposeHandle is ever passed a
- ; handle referring to a block with the resource attribute set. This usually will be a
- ; resource handle, but be aware that the resource attribute COULD be set on a
- ; non-resource handle. This isn’t likely (unless someone was a complete bonehead),
- ; but it’s possible.
- ;
- ; Greg Marriott
- ; Just Some Guy
- ; Apple Computer, Inc.
- ; 20525 Mariani Ave. MS/81-GC
- ; Cupertino, CA 95014