[comp.sys.mac.programmer] Recovering a Handle from an address in the block

olson@bootsie.UUCP (Eric Olson) (11/12/90)

Is there a socially responsible way to retrieve a Handle,
given a pointer to an address inside the block of memory
to which the Handle points?

RecoverHandle() expects a Pointer to the beginning of the
block, which isn't known.

I know this can be done by walking the heap (Macsbug does
it), but I don't really want to count on that not changing.

-Eric

-- 
Eric K. Olson, Editor, Prepare()       NOTE: olson@bootsie.uucp will not work!
Lexington Software Design              Internet: olson@endor.harvard.edu
72A Lowell St., Lexington, MA 02173    Usenet:   harvard!endor!olson
(617) 863-9624                         Bitnet:   OLSON@HARVARD

stevec@Apple.COM (Steve Christensen) (11/13/90)

In article <34@bootsie.UUCP> olson@endor.harvard.edu (Eric K. Olson) writes:
>Is there a socially responsible way to retrieve a Handle,
>given a pointer to an address inside the block of memory
>to which the Handle points?
>
>RecoverHandle() expects a Pointer to the beginning of the
>block, which isn't known.
>
>I know this can be done by walking the heap (Macsbug does
>it), but I don't really want to count on that not changing.

I think RecoverHandle() is the only socially responsible way to do this.
Any other way makes assumptions about the way heap block headers are setup,
any we all know about making assumptions.  Is there a reason why you can't
point back to the beginning of the block?

steve

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  whoami?     Steve Christensen
  snail:      Apple Computer, 20525 Mariani Ave, MS-81CS, Cupertino, CA 95035
  internet:   stevec@apple.com
  AppleLink:  stevec
  CompuServe: 76174,1712