当前位置: 首页>>代码示例>>C++>>正文


C++ CC_SAFE_FREE函数代码示例

本文整理汇总了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);
}
开发者ID:BellyWong,项目名称:CutCutCut2dx,代码行数:14,代码来源:CCParticleSystemQuad.cpp

示例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;
}
开发者ID:136446529,项目名称:book-code,代码行数:49,代码来源:CCTextureAtlas.cpp

示例3: ccArrayFree

void CCActionManager::deleteHashElement(tHashElement *&pElement)
{
    ccArrayFree(pElement->actions);
    HASH_DEL(m_pTargets, pElement);
    pElement->target->release();
    CC_SAFE_FREE(pElement);
}
开发者ID:joewan,项目名称:cocos2d-x,代码行数:7,代码来源:CCActionManager.cpp

示例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;
}
开发者ID:boruis,项目名称:cocos2dx-classical,代码行数:30,代码来源:CCUtilsAndroid.cpp

示例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);
}
开发者ID:136446529,项目名称:book-code,代码行数:16,代码来源:CCTextureAtlas.cpp

示例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;
}
开发者ID:Pythians,项目名称:PixelTest-File,代码行数:30,代码来源:ImageAlphaLut.cpp

示例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;
}
开发者ID:Pythians,项目名称:PixelTest-File,代码行数:25,代码来源:ImageAlphaLut.cpp

示例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);
	}
开发者ID:HerdiandKun,项目名称:cocos3d-x,代码行数:8,代码来源:CC3BitmapLabelNode.cpp

示例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
}
开发者ID:ADoby,项目名称:Project_Space_Pirate,代码行数:17,代码来源:CCParticleSystemQuad.cpp

示例10: CC_SAFE_FREE

bool CNData::init(void)
{
	CC_SAFE_FREE(m_pDataBuffer);
	m_pDataBuffer = NULL;
	m_iBufferLength = 0;
	m_bIsDataValid = false;
	return true;
}
开发者ID:moky,项目名称:SpriteForest,代码行数:8,代码来源:CNData.cpp

示例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;
            }
        }
    }
}
开发者ID:253056965,项目名称:cocos2d-x-lite,代码行数:45,代码来源:CCParticleSystemQuad.cpp

示例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());
}
开发者ID:Pythians,项目名称:PixelTest-File,代码行数:9,代码来源:ImageAlphaLut.cpp

示例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();
}
开发者ID:asurada,项目名称:SGLegend,代码行数:18,代码来源:PRFilledPolygon.cpp

示例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
}
开发者ID:ADoby,项目名称:Project_Space_Pirate,代码行数:19,代码来源:CCTextureAtlas.cpp

示例15: CC_SAFE_FREE

void ProgressTimer::setReverseProgress(bool reverse)
{
    if( _reverseDirection != reverse ) {
        _reverseDirection = reverse;

        //    release all previous information
        CC_SAFE_FREE(_vertexData);
        _vertexDataCount = 0;
    }
}
开发者ID:ADoby,项目名称:Project_Space_Pirate,代码行数:10,代码来源:CCProgressTimer.cpp


注:本文中的CC_SAFE_FREE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。