0

Here is an example taken from Marmalade sdk tutorial Kartz Game

//Initialise the memory manager.
MemoryManagerInit();
**{**
    CGame* game;
    **{**
        //create CGame object in 'Misc' memory bucket.
        CTempBucketSwitch b(MB_MISC);
        game = new CGame;
    **}**

    //run the game until it exits.
    game->Run();

    delete game;
**}**
//Terminate the memory manager, warning about any remaining allocations (these are leaks).
MemoryManagerTerm();

I not understand what this braces doing here? when I remove it, the program crashes

Sahka
  • 210
  • 3
  • 12

1 Answers1

2

The braces are limiting the scope of CTempBucketSwitch so it only lasts while game is getting allocated. It probably pushes a bucket called 'Misc' and pop's it when it's destroyed.

The crash is probably because the 'Misc' buckets refered to in the coment can't handle all the allocations done in the Run function.

FrankM
  • 772
  • 7
  • 11