cocos2d-x节点(b2StackAllocator.h)API
来源:互联网 发布:公司网络宣传制度 编辑:程序博客网 时间:2024/05/18 03:04
本文来自http://blog.csdn.net/runaying ,引用必须注明出处!
cocos2d-x节点(b2StackAllocator.h)API
温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记
B2StackAllocator主要是为了运行一个步长时满足box2d需要的临时内存空间,作为栈分配器来防止单步堆分配。
///cocos2d-x-3.0alpha0/external/Box2D/Common// B2StackAllocator主要是为了运行一个步长时满足box2d需要的临时内存空间,作为栈分配器来防止单步堆分配。#ifndef B2_STACK_ALLOCATOR_H#define B2_STACK_ALLOCATOR_H#include <Box2D/Common/b2Settings.h>//栈中内存池的大小 const int32 b2_stackSize = 100 * 1024; // 100kconst int32 b2_maxStackEntries = 32; //栈元素的最大数量 //栈实体定义 struct b2StackEntry{ char* data; //头指针 int32 size; //大小 bool usedMalloc; //是否使用 };// 这是一个栈分配器用于每一步都快速的分配// 你必须成对使用allocate/free这对函数。// 如果你使用allocate/free次数不同时,将会出现断言。class b2StackAllocator{public: b2StackAllocator(); //构造函数 ~b2StackAllocator(); //析构函数 void* Allocate(int32 size); //申请内存函数 ,参数说明:size :需要申请的内存大小 ,返 回 值:申请的内存头指针 void Free(void* p); //释放内存函数 参数说明:p :释放内存的头指针 int32 GetMaxAllocation() const; //获取已申请的内存容量的最大值 返 回 值:曾经进栈过所有元素【不管现在是否出栈】使用的内存容量 private: char m_data[b2_stackSize]; //栈的内存池,用于栈子节点的内存开辟 int32 m_index; //在栈的内存池中,已使用的内存大小 int32 m_allocation; //栈中的所有元素使用内存大小 int32 m_maxAllocation; //曾经进栈过所有元素【不管现在是否出栈】使用的内存容量 注意该变量在对象销毁之前只增不减 b2StackEntry m_entries[b2_maxStackEntries]; //栈实体的数组 int32 m_entryCount; //栈中元素的数量 };#endif
- cocos2d-x节点(b2StackAllocator.h)API
- cocos2d-x节点(cocos2d.h)API
- cocos2d-X 节点(CCNode.h)API
- cocos2d-X 节点(CCLayer.h)API
- cocos2d-X 节点(CCMenu.h)API
- cocos2d-X 节点(CCMenuItem.h)API
- cocos2d-X 节点(CCSprite.h)API
- cocos2d-X 节点(CCTexture2D.h)API
- cocos2d-X 节点(SpriteBatchNode.h.)API
- cocos2d-X 节点(CCSpriteFrame.h..)API
- cocos2d-X 节点(CCAnimationCache.h)API
- cocos2d-X 节点(CCCamera.h.)API
- cocos2d-X 节点(CCAction.h)API
- cocos2d-X 节点(CCActionManager.h)API
- cocos2d-X 节点(CCIMEDelegate.h)API
- cocos2d-X 节点(CCLabelAtlas.h)API
- cocos2d-X 节点(CCLabelBMFont.h)API
- cocos2d-X 节点(CCLabelTTF.h)API
- urllib2.urlopen超时问题
- SQL 简介
- cocos2d-x节点(b2Math.h)API
- cocos2d-x节点(b2Settings.h)API
- boost库之asio使用出错:error LNK2001,boost::system::generic_category
- cocos2d-x节点(b2StackAllocator.h)API
- cocos2d-x节点(b2Timer.h)API
- 汇编文件后缀 .s 与 .S
- Linux设备驱动之内存映射
- 多线程--条件变量
- 数据结构基本算法java实现
- 输出文件中不包含指定的多个排除词的行内容(双重遍历)
- wince音频驱动---1
- 那两年炼就的Android内功修养