0

これは、Marmalade sdk チュートリアル 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();

このブレースがここで何をしているのかわかりませんか?削除すると、プログラムがクラッシュします

4

1 に答える 1

2

中括弧は CTempBucketSwitch の範囲を制限しているため、ゲームが割り当てられている間だけ持続します。おそらく、「Misc」というバケツを押して、破壊されたときにポップします。

クラッシュはおそらく、コメントで参照されている「Misc」バケットが Run 関数で行われたすべての割り当てを処理できないためです。

于 2013-12-16T10:16:36.663 に答える