Michael P. Hutchens, M.D., M.A. wrote in message <11664@palm-dev-forum>...
>
>I gather there are two ways of handling CharPtr's:

Three.

>
>VoidHand JoeShmoeH;
>CharPtr JoeShmoeTxt;
>
>MemHandleNew JoeShmoeH(JOE_SIZE);
>JoeShmoeTxt = MemHandleLock(JoeShmoeH);
>
>and
> CharPtr JoeShmoeTxt[JOE_SIZE];

and
CharPtr JoeShmoeTxt;
JoeSmoeTxt = MemPtrNew(JOE_SIZE);

>
>Now my question is this:  in the first case, one simply releases the
>memory when one finishes with:
>
>MemHandleUnlock(JoeShmoeH);
>MemHandleFree(JoeShmoeH);
>
>How do you assure that the memory in the second case is released and
>not leaked?

That's just the way C (and C++) works.  You declare a local
variable on the stack when you enter the scope, and when
you leave the scope, the locals are deallocated.

Of course, if your array declaration is a global, it is never
deallocated.  ... Either way, you don't have to worry about
it being released or leaked.

--
-Richard M. Hartman
[EMAIL PROTECTED]

186,000 mi/sec: not just a good idea, it's the LAW!





-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to