"Seeley, Steve E" <[EMAIL PROTECTED]> wrote in message
news:42655@palm-dev-forum...
>
> > Hi All,
> >
> > What are the pros and cons of doing;
> >
> > CharPtr pTrunc = (CharPtr) MemPtrNew(textLen + 3); and then
> > MemPtrFree(pTrunc);
> >
> > Versus doing;
> >
> > char strTrunc[MAX_LENGTH]; and
> > letting the system free this memory when the stack is popped at
> > function end?
> >
> >
> Besides allocating only the memory required does MemPtrNew have any other
> advantages.  Is there something different about the palm OS that doesn't
> work as well when doing things the old C style way?

If you say

char strTrunc[MAX_LENGTH]

as a local variable for you function, then you've carved out MAX_LENGTH
bytes of stack space which are used while you're in your function and any
functions it calls.

Stack on the Palm is very limited -- the most stack you can use varies from
2K to 4K depending on the OS version.  You have much more dynamic heap,
ranging from 32K to 256K depending on the PalmOS version and memory size.



-- 
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