home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Macintosh Debugging / DisposeResource / DisposeResource Read Me next >
Encoding:
Text File  |  1992-10-25  |  1.4 KB  |  31 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    DisposeResource - by Greg Marriott
  3. ;
  4. ;    © 1992, Apple Computer, Inc.
  5. ;
  6. ;    DisposeResource is a debugging utility made to catch a common programming error:
  7. ;    passing a resource handle to _DisposeHandle.
  8. ;
  9. ;    The Resource Manager keeps track of in-memory resources by storing their handles
  10. ;    in the resource map.  If the block used by the resource is freed without letting the
  11. ;    resource manager know (by calling _ReleaseResource), then the handle reference will
  12. ;    not be removed from the resource map.  This can lead to crashes and data loss.
  13. ;    
  14. ;    Future allocations in the heap will likely re-use the master pointer for another
  15. ;    relocatable block.  If this happens, then the handle returned to the client will
  16. ;    be the same value as the handle in the resource map.  Magically (or sadly), the 
  17. ;    handle in the map will now suddenly refer to a random block in the heap.  This data
  18. ;    could be written out to the resource file, or trashed if _LoadResource is called on
  19. ;    the “resource” handle.
  20. ;
  21. ;    DisposeResource will break into the debugger if _DisposeHandle is ever passed a
  22. ;    handle referring to a block with the resource attribute set.  This usually will be a
  23. ;    resource handle, but be aware that the resource attribute COULD be set on a
  24. ;    non-resource handle. This isn’t likely (unless someone was a complete bonehead),
  25. ;    but it’s possible.
  26. ;    
  27. ;    Greg Marriott
  28. ;    Just Some Guy
  29. ;    Apple Computer, Inc.
  30. ;    20525 Mariani Ave. MS/81-GC
  31. ;    Cupertino, CA    95014