本文整理汇总了C++中CC_SAFE_FREE函数的典型用法代码示例。如果您正苦于以下问题:C++ CC_SAFE_FREE函数的具体用法?C++ CC_SAFE_FREE怎么用?C++ CC_SAFE_FREE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CC_SAFE_FREE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CC_SAFE_FREE
CCParticleSystemQuad::~CCParticleSystemQuad()
{
if (NULL == m_pBatchNode)
{
CC_SAFE_FREE(m_pQuads);
CC_SAFE_FREE(m_pIndices);
glDeleteBuffers(2, &m_pBuffersVBO[0]);
#if CC_TEXTURE_ATLAS_USE_VAO
glDeleteVertexArrays(1, &m_uVAOname);
#endif
}
extension::CCNotificationCenter::sharedNotificationCenter()->removeObserver(this, EVNET_COME_TO_FOREGROUND);
}
示例2: CC_SAFE_RETAIN
bool CCTextureAtlas::initWithTexture(CCTexture2D *texture, unsigned int capacity)
{
// CCAssert(texture != NULL, "texture should not be null");
m_uCapacity = capacity;
m_uTotalQuads = 0;
// retained in property
this->m_pTexture = texture;
CC_SAFE_RETAIN(m_pTexture);
// Re-initialization is not allowed
CCAssert(m_pQuads == NULL && m_pIndices == NULL, "");
m_pQuads = (ccV3F_C4B_T2F_Quad*)malloc( m_uCapacity * sizeof(ccV3F_C4B_T2F_Quad) );
m_pIndices = (GLushort *)malloc( m_uCapacity * 6 * sizeof(GLushort) );
if( ! ( m_pQuads && m_pIndices) && m_uCapacity > 0)
{
//CCLOG("cocos2d: CCTextureAtlas: not enough memory");
CC_SAFE_FREE(m_pQuads);
CC_SAFE_FREE(m_pIndices);
// release texture, should set it to null, because the destruction will
// release it too. see cocos2d-x issue #484
CC_SAFE_RELEASE_NULL(m_pTexture);
return false;
}
memset( m_pQuads, 0, m_uCapacity * sizeof(ccV3F_C4B_T2F_Quad) );
memset( m_pIndices, 0, m_uCapacity * 6 * sizeof(GLushort) );
// listen the event when app go to background
extension::CCNotificationCenter::sharedNotificationCenter()->addObserver(this,
callfuncO_selector(CCTextureAtlas::listenBackToForeground),
EVNET_COME_TO_FOREGROUND,
NULL);
this->setupIndices();
#if CC_TEXTURE_ATLAS_USE_VAO
setupVBOandVAO();
#else
setupVBO();
#endif
m_bDirty = true;
return true;
}
示例3: ccArrayFree
void CCActionManager::deleteHashElement(tHashElement *&pElement)
{
ccArrayFree(pElement->actions);
HASH_DEL(m_pTargets, pElement);
pElement->target->release();
CC_SAFE_FREE(pElement);
}
示例4: getContext
jobject CCUtilsAndroid::newIntent(const char* activityName) {
// get context
jobject context = getContext();
// find constructor
JniMethodInfo t;
JniHelper::getMethodInfo(t, "android/content/Intent", "<init>", "(Landroid/content/Context;Ljava/lang/Class;)V");
// create activity name
size_t len = strlen(activityName);
char* jniName = (char*)calloc(len + 1, sizeof(char));
for(int i = 0; i < len; i++) {
if(activityName[i] == '.')
jniName[i] = '/';
else
jniName[i] = activityName[i];
}
jclass actClass = t.env->FindClass(jniName);
// new intent
jobject intent = t.env->NewObject(t.classID, t.methodID, context, actClass);
// clear
t.env->DeleteLocalRef(actClass);
t.env->DeleteLocalRef(context);
CC_SAFE_FREE(jniName);
t.env->DeleteLocalRef(t.classID);
return intent;
}
示例5: CCLOGINFO
CCTextureAtlas::~CCTextureAtlas()
{
CCLOGINFO("cocos2d: CCTextureAtlas deallocing %p.", this);
CC_SAFE_FREE(m_pQuads);
CC_SAFE_FREE(m_pIndices);
glDeleteBuffers(2, m_pBuffersVBO);
#if CC_TEXTURE_ATLAS_USE_VAO
glDeleteVertexArrays(1, &m_uVAOname);
#endif
CC_SAFE_RELEASE(m_pTexture);
extension::CCNotificationCenter::sharedNotificationCenter()->removeObserver(this, EVNET_COME_TO_FOREGROUND);
}
示例6: initWithBuff
bool ImageAlphaLut::initWithFile(const std::string file)
{
// // 打开文件
// auto fp = fopen(FileUtils::getInstance()->fullPathForFilename(file).c_str(), "rb");
// // 获取文件大小
// fseek(fp, 0, SEEK_END);
// long fs = ftell(fp);
// rewind(fp);
auto data = FileUtils::getInstance()->getDataFromFile(file);
auto buff = data.getBytes();
data.fastSet(nullptr, 0);
// 分配文件头信息 BUFF
// unsigned char * buff = (unsigned char *)malloc(fs);
// 读取文件头信息
// size_t rs = fread(buff, sizeof(unsigned char), fs, fp);
// CCASSERT(rs == fs, "Read file info error");
// fclose(fp);
int * p = (int *)buff;
bool b = initWithBuff(++p);
CC_SAFE_FREE(buff);
return b;
}
示例7: memset
void ImageAlphaLut::moveBuffer()
{
// Move buffer
// new buffef
auto buff = static_cast<unsigned char *>(malloc(getBufferSize()));
memset(buff, 0, getBufferSize());
// 计算前面的偏移
auto offsetBuff = _width * _offsetY + _offsetX;
for (int i = 0; i < _offsetHeight; ++i)
{
for (int j = 0; j < _offsetWidth; ++j)
{
// 复制信息
if (getPixelAlpha(offsetBuff + i * _width + j)) {
copyPixelAlpha(i * _offsetWidth + j, buff);
}
}
}
// 删除原 BUFF
CC_SAFE_FREE(_alphaLut);
// 指向偏移 BUFF
_alphaLut = buff;
buff = nullptr;
}
示例8: HASH_ITER
void CC3BitmapFontConfiguration::purgeCharDefDictionary()
{
CC3BitmapCharDefHashElement *current, *tmp;
HASH_ITER(hh, m_charDefDictionary, current, tmp)
{
HASH_DEL(m_charDefDictionary, current);
CC_SAFE_FREE(current);
}
示例9: CC_SAFE_FREE
ParticleSystemQuad::~ParticleSystemQuad()
{
if (NULL == _batchNode)
{
CC_SAFE_FREE(_quads);
CC_SAFE_FREE(_indices);
glDeleteBuffers(2, &_buffersVBO[0]);
#if CC_TEXTURE_ATLAS_USE_VAO
glDeleteVertexArrays(1, &_VAOname);
GL::bindVAO(0);
#endif
}
#if CC_ENABLE_CACHE_TEXTURE_DATA
NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND);
#endif
}
示例10: CC_SAFE_FREE
bool CNData::init(void)
{
CC_SAFE_FREE(m_pDataBuffer);
m_pDataBuffer = NULL;
m_iBufferLength = 0;
m_bIsDataValid = false;
return true;
}
示例11: allocMemory
void ParticleSystemQuad::setBatchNode(ParticleBatchNode * batchNode)
{
if( _batchNode != batchNode )
{
ParticleBatchNode* oldBatch = _batchNode;
ParticleSystem::setBatchNode(batchNode);
// NEW: is self render ?
if( ! batchNode )
{
allocMemory();
initIndices();
setTexture(oldBatch->getTexture());
if (Configuration::getInstance()->supportsShareableVAO())
{
setupVBOandVAO();
}
else
{
setupVBO();
}
}
// OLD: was it self render ? cleanup
else if( !oldBatch )
{
// copy current state to batch
V3F_C4B_T2F_Quad *batchQuads = _batchNode->getTextureAtlas()->getQuads();
V3F_C4B_T2F_Quad *quad = &(batchQuads[_atlasIndex] );
memcpy( quad, _quads, _totalParticles * sizeof(_quads[0]) );
CC_SAFE_FREE(_quads);
CC_SAFE_FREE(_indices);
glDeleteBuffers(2, &_buffersVBO[0]);
memset(_buffersVBO, 0, sizeof(_buffersVBO));
if (Configuration::getInstance()->supportsShareableVAO())
{
glDeleteVertexArrays(1, &_VAOname);
GL::bindVAO(0);
_VAOname = 0;
}
}
}
}
示例12: CC_SAFE_FREE
void ImageAlphaLut::resetBuffer()
{
// 清除之前的 BUFF
CC_SAFE_FREE(_alphaLut);
// 重新分配 BUFF
_alphaLut = static_cast<unsigned char*>(malloc( getBufferSize() ));
// 初始化为 0
memset(_alphaLut, 0, getBufferSize());
}
示例13: CC_SAFE_FREE
void PRFilledPolygon::setPoints(Vector2dVector &points) {
CC_SAFE_FREE(areaTrianglePoints);
CC_SAFE_FREE(textureCoordinates);
Vector2dVector triangulatedPoints = PRRatcliffTriangulator::triangulateVertices(points);
areaTrianglePointCount = triangulatedPoints.size();
areaTrianglePoints = (CCPoint*) malloc(sizeof(CCPoint) * areaTrianglePointCount);
textureCoordinates = (CCPoint*) malloc(sizeof(CCPoint) * areaTrianglePointCount);
for (int i = 0; i < areaTrianglePointCount; i++) {
Vector2d v = (Vector2d)triangulatedPoints.at(i);
areaTrianglePoints[i] = CCPointMake(v.GetX(), v.GetY());
}
calculateTextureCoordinates();
}
示例14: CCLOGINFO
TextureAtlas::~TextureAtlas()
{
CCLOGINFO("cocos2d: TextureAtlas deallocing %p.", this);
CC_SAFE_FREE(_quads);
CC_SAFE_FREE(_indices);
glDeleteBuffers(2, _buffersVBO);
#if CC_TEXTURE_ATLAS_USE_VAO
glDeleteVertexArrays(1, &_VAOname);
GL::bindVAO(0);
#endif
CC_SAFE_RELEASE(_texture);
#if CC_ENABLE_CACHE_TEXTURE_DATA
NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND);
#endif
}
示例15: CC_SAFE_FREE
void ProgressTimer::setReverseProgress(bool reverse)
{
if( _reverseDirection != reverse ) {
_reverseDirection = reverse;
// release all previous information
CC_SAFE_FREE(_vertexData);
_vertexDataCount = 0;
}
}