[comp.sys.mac.programmer] Interesting Handle bug...

bitting-douglas@cs.yale.edu (Douglas Bitting) (04/26/91)

Well, this one has escaped me.  I have stepped though my program several times,
check return values, etc etc etc.  However, I still can't find out what is
wrong.

Basically, this is what happens:

I call someFunction() where someFunction is:

void someFunction()
{
	Handle	h1;

	[some stuff]
	h1 = NewHandle (someSmallSize);
	[some more stuff]
}

and every time I call it, h1 is set to the *same* master pointer.  I don't want
this to happen; h1 is retained to be used outside of the function (Yes, I store
the h1 away carefully in the [some more stuff] part).  I never DisposHandle(h1)
anywhere in this function, nor do I get rid of the Handle outside of the
function.  This happens whether or not I have called HNoPurge (h1); I don't get
it!  What makes it even stranger is the fact that this is the first call to
NewHandle within the function and every subsequent call works (ie, the call
returns a different master pointer each time through the loop).  It is *only*
this first call to NewHandle() within the function that get messed up!

Anyone out there have any brilliant ideas?  Please email them to me if you do.

Thanks,
-- 
Doug Bitting             | "And we know that in all things God works
PO Box 3043 Yale Station |  for the good of those who love him..."
New Haven, CT 06520      |                       --Romans 8:28
bitting@cs.yale.edu      +------------------------------------------