Hello, Lionel.

on 99.11.9 6:18 PM, Lionel Bonnet at [EMAIL PROTECTED] wrote:

> The 32K limit doesn't really exists on PowerPC : in each application memory
> zone, you have the stack zone and the heap zone.There is a default stack
> zone(32 K)but if you want to increase it, you must change the limit of the
> heap, and so the limit of the stack.
> So you must insert this code at the very beginning of the application :
> 
> stkNeeded=StackNeeded();
> if (stkNeeded > StackSpace())
> {
> SetApplLimit((Ptr) ((long) GetApplLimit() - stkNeeded + StackSpace()));
> }
> heapSize = (long) GetApplLimit() - (long) ApplicationZone();

I know, of course, stack meaning, though, this is not such a problem, I
think. We can easily increase stack size with project settings -> target ->
PPC target -> stack size (default 64K) in CW.

I wrote following test code, but could not compile. The line,

    char chunk[64*1024L];

is smaller than 128*1024L, and there may be enough remnant of stack,
however, CW tells me "local data is larger than 32K". I do think, locak data
is not equal to stack. Local data may mean local variables in specific
funcion.

How can I break though this limit? I ask this in general macintosh
programming mailing list, people says, "There is no way. Make it global or
static."

Do I misunderstand?

TIA.

#include <string.h> /* for memset */

#include <Types.h>
#include <Memory.h>
#include <Quickdraw.h>
#include <Fonts.h>
#include <Events.h>
#include <Menus.h>
#include <Windows.h>
#include <TextEdit.h>
#include <Dialogs.h>
#include <OSUtils.h>
#include <ToolUtils.h>
#include <SegLoad.h>
#include <Sound.h>

void Initialize(void);

int main(void)
{
    long stkNeeded /*, heapSize */;
    
    Initialize();
    
    stkNeeded = 128*1024L; /* StackNeeded(); */
    if (stkNeeded > StackSpace())
    {
        SetApplLimit((Ptr) ((long) GetApplLimit() - stkNeeded +
StackSpace()));
    }
    /* heapSize = (long) GetApplLimit() - (long) ApplicationZone(); */
    
    do {
    } while (!Button());

    return 0;    
}

void Initialize(void)
{
    InitGraf(&qd.thePort);
    InitFonts();
    InitWindows();
    InitMenus();
    TEInit();
    InitDialogs(nil);
    InitCursor();
}

void foo(void)
{
    char chunk[64*1024L];
    memset(chunk, 0x00, 64*1024L);
}

--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )

Reply via email to