At 10:56 AM 4/13/99 -0500, you wrote:
>Is the handle only on the stack while locked?
>
The handle is on the stack for the duration of the function (including any
sub-functions), or its scope within the function. For example:
VoidHand Foo (UInt allocSize)
{
VoidHand returnH = NULL;
// Stack A
if (allocSize > 0)
{
VoidHand allocH = MemHandleNew (allocSize);
// Stack B
// Do a bunch of stuff.
DoStuff (allocH);
returnH = allocH;
}
// Stack C
return returnH;
}
// Stack D
For the purposes of this discussion, when we enter the function (Stack A),
only returnH is on the stack. When we go into the if statement's scope
(Stack B) , we add another handle, allocH, onto the stack. When we exit
the if statement's scope (Stack C), we're back to having only returnH on
the stack. Finally, when we leave the function (Stack D), none of these
handles are on the stack. If we were to trace into the function DoStuff (
), both returnH and allocH would *still* be on the stack, even though they
would not be accessible from inside DoStuff ( ). If this isn't clear,
e-mail me separately and we can discuss how programs use the stack in way
more depth than is appropriate here.
Bear in mind, though, that if we haven't freed the memory to which returnH
and allocH are handles, this memory is still allocated. This is an issue
only of the scope of the handle variables that refer to it.
Also, this is a simplification. There is a lot going on with the stack in
addition to this
>Immensely. I've printed it out and punched it into the API binders. Thank
>you.
>
Wow. I'm flattered.
Greg Winton
Bachmann Software and Services, LLC
mailto:[EMAIL PROTECTED]
http://www.bachmannsoftware.com
Software Development for Handheld & Mobile Computing, Windows and the Internet
Home of Bachmann Print Manager, the only graphical printing solution for
the Palm Computing Platform