XRtn EvalExpHandle() Handle owner

External developers... This forum's for you!

XRtn EvalExpHandle() Handle owner

Postby Dave_Higgins » Wed Oct 20, 2010 11:49 am

In xrtnRT.h

Code: Select all
result EvalExpHandle(message, destination)
...
destination   <-:address of handle, SuperCard will create the new handle

I assume we would want to set up destination with...
Handle destHandle; // or...
Handle destHandle = NULL;

... prior to calling EvalExpHandle(), but what's not indicated is ownership of the destination handle. Is it up to us to dispose destHandle, or will SC take care of it? My initial thought is that SC will take care of it, but I don't want to go leaving Handles laying around that I'm supposed to be sweeping up.
My two favorite teams are Detroit and whoever's playing Chicago.
User avatar
Dave_Higgins
 
Posts: 454
Joined: Mon Jul 07, 2008 9:50 am
Location: Dark Side Of The Moon

Re: XRtn EvalExpHandle() Handle owner

Postby codegreen » Thu Oct 21, 2010 8:04 am

Dave Higgins wrote:In xrtnRT.h

Code: Select all
result EvalExpHandle(message, destination)
...
destination   <-:address of handle, SuperCard will create the new handle

I assume we would want to set up destination with...
Handle destHandle; // or...
Handle destHandle = NULL;

... prior to calling EvalExpHandle(), but what's not indicated is ownership of the destination handle. Is it up to us to dispose destHandle, or will SC take care of it? My initial thought is that SC will take care of it, but I don't want to go leaving Handles laying around that I'm supposed to be sweeping up.

ANY time you're asked to pass the address of a Handle to a routine for it to return some data in, you should expect that routine to allocate the Handle for you, and assume that the Handle will belong to you from that point on. This applies to ALL Carbon and classic Toolbox code, not just to externals. Whether or not you zero out the Handle first is entirely up to you, but doing so definitely makes it more obvious whether you've gotten a value back or not.

-Mark
codegreen
 
Posts: 1510
Joined: Mon Jul 14, 2008 11:03 pm


Return to Xcode and the Internals Toolbox

Who is online

Users browsing this forum: No registered users and 1 guest