home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!apple!goofy!mumbo.apple.com!gallant.apple.com!apple.com!noah
- From: noah@apple.com (Noah Price)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Duplicate Object in Think C?
- Message-ID: <noah-060193165521@noah.apple.com>
- Date: 7 Jan 93 01:03:21 GMT
- References: <white.724729120@sfu.ca> <1992Dec19.002858.299@physc1.byu.edu> <d!q2saf@rpi.edu> <1993Jan5.015329.15824@reed.edu> <noah-050193094549@noah.apple.com> <1993Jan6.084330.7697@netcom.com>
- Sender: news@gallant.apple.com
- Followup-To: comp.sys.mac.programmer
- Organization: (not the opinions of) Apple Computer, Inc.
- Lines: 21
-
- In article <1993Jan6.084330.7697@netcom.com>, mspace@netcom.com (Brian
- Hall) wrote:
- > You would want to copy the dat itself in case you end up disposing the
- > object. If you have two copies of an object (that have a handle as
- > instance data) then disposing the first object will leave a "dangling
- > handle" in the second object - the handle will not be NULL, but it won't
- > be pointing to anything you would want it to!
-
- If you don't want two copies of the data, though, you could have one object
- "own" the data. For example, CArrayPane does something like this for its
- array. Only the "owner" disposes of the data.
-
- Also, using ForgetObject and ForgetHandle helps, since they NULL the handle
- rather than leaving it randomly dangling. Then you can check for a NULL
- handle before using it to make sure it's valid.
-
- noah
-
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- noah@apple.com Macintosh Hardware Design
- ...!{sun,decwrl}!apple!noah (not the opinions of) Apple Computer, Inc.
-