Another thing that might be better (and more widely compatible) than setting
the stack larger, is to turn off the stack related compiler optimization.
Metrowerks (and IIRC also GCC) pushes function call arguments onto the stack
... but does not pop them until the function returns (or in certain looping
situations).  This makes the code size smaller (actually, it may only do
that for system traps).  But it chews through the stack like there's no
tomorrow.  This often causes Hacks to be unnecessarily prone to crashes.

Anyway, you might be able to solve the stack problem by telling the compiler
to pop arguments immediately.  In CodeWarrior you can use:

#pragma stack_cleanup on
// implementation of function(s) for which you want the
// compiler to use the stack frugally
#pragma stack_cleanup reset

Or another solution would be to allocate a bunch of memory up front in a
single MemPtrNew call, if you can determine a similarity between the buffers
you need.  (Or you could implement a simple zone heap, depending on exactly
what kind of memory usage you need).


"Chris Apers" <[EMAIL PROTECTED]> wrote in message
news:109928@palm-dev-forum...
>
> What is the max size of the stack ?
>
> ----- Original Message -----
> From: "Ben Combee" <[EMAIL PROTECTED]>
> To: "Palm Developer Forum" <[EMAIL PROTECTED]>
> Sent: Monday, January 20, 2003 6:28 PM
> Subject: Re: stack overflowed
>
>
> > At 17:49 2003-1-20 +0100, you wrote:
> > >Hi,
> > >
> > >Is there a way to increase stack size ?
> > >Because i have a stack overflow. And if i use :
> > >     Char *buf = (Char *)MemPtrNew(256);
> > >instead of
> > >     Char buf[256];
> > >in my function, my program extremely slow down.
> >
> > Yes.
> >
> > If you're using CodeWarrior for Palm OS with Constructor, there is a
stack
> > size setting in the application resources ar the bottom of the
Constructor
> > resource list window.
> >
> > If you're using CW for Palm OS V9 with the Palm OS 68K linker, you
should
> > be able to specify this using the 68K Palm OS Target pref panel...
> however,
> > there is a bug here, and the wrong resource ID is created, so instead
you
> > need an entry in a RCP file that says:
> >
> > HEX "pref" ID 0 0x00 0x1e 0x00 0x00 0x10 0x00 0x00 0x00 0x10 0x00
> >
> > where hex numbers 2-5 represent the new stack size.
> >
> > If you're using prc-tools, I'm fairly sure stack size is an option you
can
> > pass to build-prc.
> >
> > --
> > Ben Combee <[EMAIL PROTECTED]>
> > CodeWarrior for Palm OS technical lead
> > Palm OS programming help @ www.palmoswerks.com
> >
> >
> > --
> > For information on using the Palm Developer Forums, or to unsubscribe,
> please see http://www.palmos.com/dev/support/forums/
> >
>
>



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

Reply via email to