Changing the Stack Size
Changing the Stack Size
// Changing the Stack Size
// Demonstration of how to change your stack size
// Assuming inclusion of .
/* Globals */
long bytes;
OSErr error;
OSErr addtostack (long n bytes);
OSErr setstack (long n bytes);
OSErr DoError (OSErr error);
// addtostack()
// expands stack based on current stack size
OSErr addtostack(long n bytes)
{
return(MemError());
}
// setstack()
// sets the stack to the size you want it
OSErr setstack (long n bytes)
{
SetApplLimit((Ptr) (CurStackBase - n bytes));
return(MemError());
}
main()
{
/**** Change this variable to add more space ************/
bytes = 32000L;
if (( error=setstack( bytes)) == noErr) {
// Call MaxApplZone to shove the heap right to the top of
// where we said it can live.
// Put your application code here
}
else
DoError ( error);
}