您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CC_SAFE_DELETE_ARRAY函数代码示例

51自学网 2021-06-01 19:57:46
  C++
这篇教程C++ CC_SAFE_DELETE_ARRAY函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中CC_SAFE_DELETE_ARRAY函数的典型用法代码示例。如果您正苦于以下问题:C++ CC_SAFE_DELETE_ARRAY函数的具体用法?C++ CC_SAFE_DELETE_ARRAY怎么用?C++ CC_SAFE_DELETE_ARRAY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了CC_SAFE_DELETE_ARRAY函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: CC_SAFE_RELEASE

	CCTMXLayer::~CCTMXLayer()	{		CC_SAFE_RELEASE(m_pTileSet);		CC_SAFE_RELEASE(m_pReusedTile);		CC_SAFE_RELEASE(m_pProperties);		if( m_pAtlasIndexArray )		{			ccCArrayFree(m_pAtlasIndexArray);			m_pAtlasIndexArray = NULL;		}		CC_SAFE_DELETE_ARRAY(m_pTiles);	}
开发者ID:Pentaloop,项目名称:Loop2d,代码行数:14,


示例2: glPixelStorei

void CARenderImage::end(){    GLubyte *pBuffer = pBuffer = new GLubyte[m_uPixelsWide * m_uPixelsHigh * 4];    GLubyte *pTempData = new GLubyte[m_uPixelsWide * m_uPixelsHigh * 4];        glPixelStorei(GL_PACK_ALIGNMENT, 1);    glReadPixels(0, 0, m_uPixelsWide, m_uPixelsHigh, GL_RGBA, GL_UNSIGNED_BYTE, pTempData);    glBindFramebuffer(GL_FRAMEBUFFER, m_nOldFBO);    CAApplication::getApplication()->setViewport();    kmGLMatrixMode(KM_GL_PROJECTION);	kmGLPopMatrix();	kmGLMatrixMode(KM_GL_MODELVIEW);	kmGLPopMatrix();    m_pImage = new CAImage();    m_pImage->initWithRawData(pTempData, CAImage::PixelFormat_RGBA8888, m_uPixelsWide, m_uPixelsHigh);    m_pImageView->setImage(m_pImage);    m_pImage->release();    CC_SAFE_DELETE_ARRAY(pBuffer);    CC_SAFE_DELETE_ARRAY(pTempData);}
开发者ID:DreamCastleShanghai,项目名称:dkomClient,代码行数:23,


示例3: CC_BREAK_IF

bool PhysicsShapeEdgePolygon::init(const Point* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/){    cpVect* vec = nullptr;    do    {        CC_BREAK_IF(!PhysicsShape::init(Type::EDGEPOLYGEN));                vec = new cpVect[count];        PhysicsHelper::points2cpvs(points, vec, count);        _center = PhysicsHelper::cpv2point(cpCentroidForPoly(count, vec));                int i = 0;        for (; i < count; ++i)        {            cpShape* shape = cpSegmentShapeNew(_info->getSharedBody(), vec[i], vec[(i+1)%count],                                               PhysicsHelper::float2cpfloat(border));            CC_BREAK_IF(shape == nullptr);			cpShapeSetElasticity(shape, 1.0f);			cpShapeSetFriction(shape, 1.0f);            _info->add(shape);        }        CC_SAFE_DELETE_ARRAY(vec);                CC_BREAK_IF(i < count);                _mass = PHYSICS_INFINITY;        _moment = PHYSICS_INFINITY;                setMaterial(material);                return true;    } while (false);        CC_SAFE_DELETE_ARRAY(vec);        return false;}
开发者ID:12white,项目名称:CocoStudioSamples,代码行数:37,


示例4: createCCDictionaryWithData

CCDictionary* createCCDictionaryWithData(unsigned char* data){    CCAssert((data),"data must not be NULL!!!");        CCDictMaker tMaker;	CCDictionary* dict = tMaker.dictionaryWithData(data);	    if (dict != NULL)    {        dict->autorelease();    }	CC_SAFE_DELETE_ARRAY(data);		return dict;}
开发者ID:QiuleiWang,项目名称:cocos2d-x-2.x-utils,代码行数:15,


示例5: new

bool PhysicsShapeEdgePolygon::init(const Vec2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/){    cpVect* vec = nullptr;    do    {        _type = Type::EDGEPOLYGEN;                vec = new (std::nothrow) cpVect[count];        PhysicsHelper::points2cpvs(points, vec, count);                int i = 0;        for (; i < count; ++i)        {            auto shape = cpSegmentShapeNew(s_sharedBody, vec[i], vec[(i + 1) % count], border);            CC_BREAK_IF(shape == nullptr);            cpShapeSetUserData(shape, this);            cpShapeSetElasticity(shape, 1.0f);            cpShapeSetFriction(shape, 1.0f);            addShape(shape);        }        CC_SAFE_DELETE_ARRAY(vec);                CC_BREAK_IF(i < count);                _mass = PHYSICS_INFINITY;        _moment = PHYSICS_INFINITY;                setMaterial(material);                return true;    } while (false);        CC_SAFE_DELETE_ARRAY(vec);        return false;}
开发者ID:114393824,项目名称:Cocos2dxShader,代码行数:36,


示例6: createCCArrayWithData

CCArray* createCCArrayWithData(unsigned char* data){    CCAssert((data),"data must not be NULL!!!");        CCDictMaker tMaker;	CCArray* array = tMaker.arrayWithData(data);        if (array != NULL)    {        array->autorelease();    }    CC_SAFE_DELETE_ARRAY(data);        return array;}
开发者ID:QiuleiWang,项目名称:cocos2d-x-2.x-utils,代码行数:15,


示例7: HpCharactor

HpCharactor* HpCharactorBinParser::parse(const char* p_file){        m_cur_chara = new HpCharactor();    HpBinaryReader* reader = NULL;        const string& full_path = CCFileUtils::sharedFileUtils()->fullPathForFilename(p_file);        unsigned long size = 0;    char* pBuffer = (char*)CCFileUtils::sharedFileUtils()->getFileData(full_path.c_str(), "rt", &size);    if (pBuffer != NULL && size > 0)    {        reader = new HpBinaryReader(pBuffer, size);    }        char buffer[128] = {0};        reader->ReadChars(buffer, 3);    if (strncasecmp(buffer, "CHR", 3) != 0) return NULL;        ChrReadingVersion = reader->ReadByte();        if (ChrReadingVersion > ChrReadingVersionMax) {        CCLOG("HpCharactorBinParser max reader version is %d, but the file version is %d", ChrReadingVersionMax, ChrReadingVersion);        CCAssert(0, "");        return NULL;    }        Byte plist_count = reader->ReadByte();    for(int i=0; i<plist_count;i++)    {        reader->ReadString(buffer);        char* p = strrchr(buffer, '//');        m_cur_chara->getPLists()->addObject(CCString::create(p ? p+1 : buffer));    }        unsigned short anim_count = reader->ReadUInt16();    for(int i=0; i<anim_count; i++) {        readAnimation(reader, buffer);    }        reader->Close();    CC_SAFE_DELETE(reader);    CC_SAFE_DELETE_ARRAY(pBuffer);            return m_cur_chara;}
开发者ID:hyizsg,项目名称:mytest1st,代码行数:48,


示例8: atoi

void ObstacleManager::ReadFile(std::string fileName , std::string &obsPattern , int index){    #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)    {        std::ifstream fin;        std::string thisline;                fin.open(CCFileUtils::sharedFileUtils()->fullPathForFilename(fileName.c_str()).c_str());        fin>>thisline; //reading pattern Distance..                allObstacleChunks[index].patternDistance = atoi(thisline.c_str()); //assigning                fin>>thisline;        obsPattern = thisline;        fin.close();            }#else    {        unsigned long size = 0;        char* pBuffer = (char*)CCFileUtils::sharedFileUtils()->getFileData(fileName.c_str(), "rt", &size);        int count = 0;        std::string patternDistance = "";        for (int i = count ; pBuffer[i] != '/n' ; i++ )        {            patternDistance += pBuffer[i];            count++;        }                count++;                allObstacleChunks[index].patternDistance = atoi(patternDistance.c_str());                std::string line = "";        for (int j = count ; pBuffer[j] != '/n' ; j++ )        {            line += pBuffer[j];            count++;        }        count++;        coinPattern = line.c_str();        CC_SAFE_DELETE_ARRAY(pBuffer);    }#endif}
开发者ID:jojizaidi,项目名称:Gnome,代码行数:48,


示例9: memset

const char* Utils::readRC4LuaFile(const char* fileName){	readFromFile    unsigned long size = 0;    unsigned char* pData = cocos2d::CCFileUtils::sharedFileUtils()->getFileData(fileName, "rb", &size);        std::string OUTKEY = Utils::getOutKeyFile();    char *temp = new char[size + 1];	memset(temp, 0, size + 1);    rc4_state state;    rc4_init(&state, (const u_char *)OUTKEY.c_str(), OUTKEY.size());    rc4_crypt(&state, (const u_char *)pData, (u_char *)temp, size);        CC_SAFE_DELETE_ARRAY(pData);    return temp;}
开发者ID:LeoYangLing,项目名称:Client,代码行数:16,


示例10: glGetActiveUniform

void CC3GLSLUniform::populateFromGL(){	if ( _program == NULL )		return;	GLint maxNameLen = _program->getMaxUniformNameLength();	char* cName = new char[maxNameLen];	glGetActiveUniform( _program->getProgramID(), _index, maxNameLen, NULL, &_size, &_type, cName );	_location = glGetUniformLocation( _program->getProgramID(), cName );	_name = cName;	CC_SAFE_DELETE_ARRAY( cName );}
开发者ID:HerdiandKun,项目名称:cocos3d-x,代码行数:16,


示例11: CC_BREAK_IF

bool CCComAttribute::parse(const std::string &jsonPath){    bool bRet = false;    unsigned long size = 0;    unsigned char *pBytes = NULL;    do {          pBytes = cocos2d::CCFileUtils::sharedFileUtils()->getFileData(jsonPath.c_str(), "r", &size);          CC_BREAK_IF(pBytes == NULL || strcmp((char*)pBytes, "") == 0);          std::string load_str((const char*)pBytes, size);          CC_SAFE_DELETE_ARRAY(pBytes);          _doc.Parse<0>(load_str.c_str());          CC_BREAK_IF(_doc.HasParseError());          bRet = true;        } while (0);    return bRet;}
开发者ID:1901,项目名称:cocos2d-x,代码行数:16,


示例12: textString

// Load local file "text_[LanguageCode].json"bool THLocalizer::load(){    // Load file    std::string fileName = this->withLocaleString("pkg_common/json/text.json");    /*     * cocos2dx v2.1.4 deplicated CCFileUtils::fullPathFromRelativePath()     * CCFileUtils::fullPathFromRelativePath() is not thread-safe, it use autorelease().     *     * std::string path = cocos2d::CCFileUtils::sharedFileUtils()->     * fullPathFromRelativePath(fileName.c_str());     */    std::string path = cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(fileName.c_str());    // When localization file is not exists//	if(!THFileUtil::existFile(path.c_str()))//	{//		return false;//	}    // in android, doesn't work.    unsigned long nSize = 0;    unsigned char* pBuffer =        cocos2d::CCFileUtils::sharedFileUtils()->getFileData(            path.c_str(),            "rb",            &nSize        );    // Parse user default file    std::string textString(reinterpret_cast<const char *>(pBuffer), nSize);    // Add LeeYJ, Memory leak.    CC_SAFE_DELETE_ARRAY(pBuffer);    Json::Reader jsonReader;    bool isParsed = jsonReader.parse(textString.c_str(), m_tLocalizeData);    if(!isParsed)    {        m_tLocalizeData = 0;        return false;    }    return true;}
开发者ID:JeonJonguk,项目名称:e002_c010,代码行数:48,


示例13: ccDrawCardinalSpline

void ccDrawCardinalSpline( CCPointArray *config, float tension,  unsigned int segments ){    lazy_init();    ccVertex2F* vertices = new ccVertex2F[segments + 1];    unsigned int p;    float lt;    float deltaT = 1.0f / config->count();    for( unsigned int i=0; i < segments+1; i++) {        float dt = (float)i / segments;        // border        if( dt == 1 ) {            p = config->count() - 1;            lt = 1;        } else {            p = dt / deltaT;            lt = (dt - deltaT * (float)p) / deltaT;        }        // Interpolate        CCPoint pp0 = config->getControlPointAtIndex(p-1);        CCPoint pp1 = config->getControlPointAtIndex(p+0);        CCPoint pp2 = config->getControlPointAtIndex(p+1);        CCPoint pp3 = config->getControlPointAtIndex(p+2);        CCPoint newPos = ccCardinalSplineAt( pp0, pp1, pp2, pp3, tension, lt);        vertices[i].x = newPos.x;        vertices[i].y = newPos.y;    }    s_pShader->use();    s_pShader->setUniformsForBuiltins();    s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*)&s_tColor.r, 1);    ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );    glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);    glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1);    CC_SAFE_DELETE_ARRAY(vertices);    CC_INCREMENT_GL_DRAWS(1);}
开发者ID:Ratel13,项目名称:cocos2dx-swf,代码行数:46,


示例14: drawPoints

void drawPoints( const Vec2 *points, unsigned int numberOfPoints ){    lazy_init();    GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );    s_shader->use();    s_shader->setUniformsForBuiltins();    s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1);    s_shader->setUniformLocationWith1f(s_pointSizeLocation, s_pointSize);    // FIXME: Mac OpenGL error. arrays can't go out of scope before draw is executed    Vec2* newPoints = new (std::nothrow) Vec2[numberOfPoints];    // iPhone and 32-bit machines optimization    if( sizeof(Vec2) == sizeof(Vec2) )    {#ifdef EMSCRIPTEN        setGLBufferData((void*) points, numberOfPoints * sizeof(Vec2));        glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);#else        glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, points);#endif // EMSCRIPTEN    }    else    {        // Mac on 64-bit        for( unsigned int i=0; i<numberOfPoints;i++) {            newPoints[i].x = points[i].x;            newPoints[i].y = points[i].y;        }#ifdef EMSCRIPTEN        // Suspect Emscripten won't be emitting 64-bit code for a while yet,        // but want to make sure this continues to work even if they do.        setGLBufferData(newPoints, numberOfPoints * sizeof(Vec2));        glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);#else        glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoints);#endif // EMSCRIPTEN    }    glDrawArrays(GL_POINTS, 0, (GLsizei) numberOfPoints);    CC_SAFE_DELETE_ARRAY(newPoints);    CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, numberOfPoints);}
开发者ID:fdmjyoshi3,项目名称:cocos2d-x,代码行数:46,


示例15: while

void EffectManager::readData(const char* filename){	ssize_t fileLen = 0;	unsigned char *fileData = NULL;	fileData = CCFileUtils::sharedFileUtils()->getFileData(CCFileUtils::sharedFileUtils()->fullPathForFilename(filename).c_str(), "rb", (ssize_t *)(&fileLen));	unsigned char* temp = fileData;	unsigned long pos = 0;	while (pos<(fileLen-1))	{		EffectConfigData configData;		configData.encode(fileData, pos);		effctConfigDataDic.insert(std::map<std::string, EffectConfigData>::value_type(configData.m_effectName, configData));	}	CC_SAFE_DELETE_ARRAY(temp);}
开发者ID:lure9999,项目名称:Nodie,代码行数:17,


示例16: ccDrawPoints

void ccDrawPoints( const CCPoint *points, unsigned int numberOfPoints ){    lazy_init();    ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );    s_pShader->use();    s_pShader->setUniformsForBuiltins();    s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);    s_pShader->setUniformLocationWith1f(s_nPointSizeLocation, s_fPointSize);    // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed    ccVertex2F* newPoints = new ccVertex2F[numberOfPoints];    // iPhone and 32-bit machines optimization    if( sizeof(CCPoint) == sizeof(ccVertex2F) )    {#ifdef EMSCRIPTEN        setGLBufferData((void*) points, numberOfPoints * sizeof(CCPoint));        glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);#else        glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, points);#endif // EMSCRIPTEN    }    else    {        // Mac on 64-bit        for( unsigned int i=0; i<numberOfPoints;i++) {            newPoints[i].x = points[i].x;            newPoints[i].y = points[i].y;        }#ifdef EMSCRIPTEN        // Suspect Emscripten won't be emitting 64-bit code for a while yet,        // but want to make sure this continues to work even if they do.        setGLBufferData(newPoints, numberOfPoints * sizeof(ccVertex2F));        glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);#else        glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoints);#endif // EMSCRIPTEN    }    glDrawArrays(GL_POINTS, 0, (GLsizei) numberOfPoints);    CC_SAFE_DELETE_ARRAY(newPoints);    CC_INCREMENT_GL_DRAWS(1);}
开发者ID:1085075003,项目名称:quick-cocos2d-x,代码行数:46,


示例17: CC_SAFE_DELETE_ARRAY

CCBReader::~CCBReader() {    CC_SAFE_DELETE_ARRAY(this->mBytes);    this->mCCNodeLoaderLibrary->release();    /* Clear string cache. */    std::vector<CCString *>::iterator stringCacheIterator;    for (stringCacheIterator = this->mStringCache.begin(); stringCacheIterator != this->mStringCache.end(); stringCacheIterator++) {        (*stringCacheIterator)->release();    }    this->mStringCache.clear();        if(this->mRootCCBReader) {        /* Clear loaded spritesheets. */        this->mLoadedSpriteSheets.clear();    }}
开发者ID:rohankuruvilla,项目名称:cocos2dx-chipmunk-js,代码行数:17,


示例18: CC_CONTENT_SCALE_FACTOR

    void CCLabelTTF::setFontSize(float fontSize)    {        if (m_fFontSize != fontSize * CC_CONTENT_SCALE_FACTOR())        {            m_fFontSize = fontSize * CC_CONTENT_SCALE_FACTOR();            // Force update            if (m_pString&& m_pString->size() > 0)            {                const char* str = m_pString->c_str();                char* tmp = new char[strlen(str)+1];                strcpy(tmp,str);                this->setString(tmp);                CC_SAFE_DELETE_ARRAY(tmp);            }        }    }
开发者ID:tungt84,项目名称:cocos2d-blackberry,代码行数:17,


示例19: drawCardinalSpline

void drawCardinalSpline( PointArray *config, float tension,  unsigned int segments ){    lazy_init();    Vec2* vertices = new (std::nothrow) Vec2[segments + 1];    ssize_t p;    float lt;    float deltaT = 1.0f / config->count();    for( unsigned int i=0; i < segments+1;i++) {        float dt = (float)i / segments;        // border        if( dt == 1 ) {            p = config->count() - 1;            lt = 1;        } else {            p = dt / deltaT;            lt = (dt - deltaT * (float)p) / deltaT;        }        // Interpolate        Vec2 pp0 = config->getControlPointAtIndex(p-1);        Vec2 pp1 = config->getControlPointAtIndex(p+0);        Vec2 pp2 = config->getControlPointAtIndex(p+1);        Vec2 pp3 = config->getControlPointAtIndex(p+2);        Vec2 newPos = ccCardinalSplineAt( pp0, pp1, pp2, pp3, tension, lt);        vertices[i].x = newPos.x;        vertices[i].y = newPos.y;    }    s_shader->use();    s_shader->setUniformsForBuiltins();    s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*)&s_color.r, 1);    GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);    glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1);    CC_SAFE_DELETE_ARRAY(vertices);    CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,segments+1);}
开发者ID:114393824,项目名称:Cocos2dxShader,代码行数:46,


示例20: TiXmlDocument

void ParticleFactory::InitXML(){	std::string pPath = 		GameResourceManager::sharedManager()->storedFullPathFromRelativePath("Data/particles.xml");	unsigned long	_size;	char			*_pFileContent = (char*)CCFileUtils::sharedFileUtils()->getFileData(pPath.c_str() , "r", &_size);	TiXmlDocument	*_document = new TiXmlDocument();	_document->Parse(_pFileContent, 0, TIXML_ENCODING_UTF8);	CC_SAFE_DELETE_ARRAY(_pFileContent);	TiXmlElement *RootElement = _document->RootElement();	if (RootElement)	{		TiXmlElement *childElement = RootElement->FirstChildElement();		while (0 != childElement)		{			OneParticleInfo oneParticleInfo;			TiXmlAttribute* pAttribute = childElement->FirstAttribute();			while(pAttribute)			{				std::string strName(pAttribute->Name());				std::string content = childElement->Attribute(strName.c_str());				if (strName == "ID")				{					unsigned int id = atoi(content.c_str());					oneParticleInfo.id = id;				}				else if (strName == "fileName")				{					oneParticleInfo.fileName = content;				}				pAttribute = pAttribute->Next();			}			m_particleListInfo.insert(std::make_pair(oneParticleInfo.id,oneParticleInfo));			childElement = childElement->NextSiblingElement();		}		TiXmlDocument *doc = RootElement->GetDocument();		doc->Clear();		CC_SAFE_DELETE(doc);	}}
开发者ID:niuzb,项目名称:hellopet,代码行数:45,


示例21: CC_BREAK_IF

bool CCComRender::readJson(const char *pszFileName, rapidjson::Document &doc){    bool bRet = false;    unsigned long size = 0;    unsigned char *pBytes = NULL;    do {        CC_BREAK_IF(pszFileName == NULL);        std::string jsonpath = CCFileUtils::sharedFileUtils()->fullPathForFilename(pszFileName);        pBytes = cocos2d::CCFileUtils::sharedFileUtils()->getFileData(jsonpath.c_str(), "r", &size);        CC_BREAK_IF(pBytes == NULL || strcmp((char*)pBytes, "") == 0);        std::string load_str((const char*)pBytes, size);        CC_SAFE_DELETE_ARRAY(pBytes);        doc.Parse<0>(load_str.c_str());        CC_BREAK_IF(doc.HasParseError());        bRet = true;    } while (0);    return bRet;}
开发者ID:ECNU-ZR,项目名称:physwf-c-lab,代码行数:18,


示例22: cpPolyShapeGetCount

float PhysicsShapePolygon::calculateDefaultMoment(){    if(_mass == PHYSICS_INFINITY)    {        return PHYSICS_INFINITY;    }    else    {        auto shape = _cpShapes.front();        int count = cpPolyShapeGetCount(shape);        cpVect* vecs = new cpVect[count];        for(int i=0;i<count;++i)            vecs[i] = cpPolyShapeGetVert(shape, i);        float moment = PhysicsHelper::cpfloat2float(cpMomentForPoly(_mass, count, vecs, cpvzero, cpPolyShapeGetRadius(shape)));        CC_SAFE_DELETE_ARRAY(vecs);        return moment;    }}
开发者ID:114393824,项目名称:Cocos2dxShader,代码行数:18,


示例23: CC_SAFE_DELETE

GameScene::~GameScene(){    CC_SAFE_DELETE(_background1);    CC_SAFE_DELETE(_background2);    CC_SAFE_DELETE(_background3);    CC_SAFE_DELETE(_background4);    CC_SAFE_DELETE(_backgroundNode);    CC_SAFE_DELETE(_flyingChickenNode);    CC_SAFE_DELETE(_gameBatchNode);    CC_SAFE_DELETE(_gameLogic);    CC_SAFE_DELETE(_GUINode);    CC_SAFE_DELETE(_player);    CC_SAFE_DELETE(_rotatingShell);    CC_SAFE_DELETE_ARRAY(_rotatingShells);    CC_SAFE_DELETE(_sky);        }
开发者ID:xgeraldx,项目名称:ChickenHunt,代码行数:18,


示例24: CC_BREAK_IF

void GameData::readQuestsDataFile(){	std::string jsonPath = QUESTS_DATA_PATH;	rapidjson::Document _doc;	ssize_t size = 0;	unsigned char *pBytes = NULL;	do {		pBytes = FileUtils::getInstance()->getFileData(jsonPath, "r", &size);		CC_BREAK_IF(pBytes == NULL || strcmp((char*)pBytes, "") == 0);		std::string load_str((const char*)pBytes, size);		CC_SAFE_DELETE_ARRAY(pBytes);		_doc.Parse<0>(load_str.c_str());		CC_BREAK_IF(_doc.HasParseError());		// 判断是否为一个数组		if (!_doc.IsArray())			return;		const rapidjson::Value& pArray = _doc;		for (rapidjson::SizeType i = 0; i < pArray.Size(); i++)		{			QuestListData* data = new QuestListData();			const rapidjson::Value &value = pArray[i];  // value为一个对象			data->id = value["id"].GetInt();			data->level = value["level"].GetInt();			data->mapID = value["mapID"].GetInt();			data->title = value["title"].GetString();			data->instruct = value["instruct"].GetString();			data->type = value["type"].GetInt();			data->status = value["status"].GetInt();			const rapidjson::Value &mArray = value["mons_id"];			for (int i = 0; i < mArray.Size(); i++) {				data->mons_id.push_back(mArray[i].GetInt());			}			const rapidjson::Value &fArray = value["forgeID"];			for (int i = 0; i < fArray.Size(); i++) {				data->forgeID.push_back(fArray[i].GetInt());			}			data->targetNpc = value["targetNpc"].GetString();			data->launchNpc = value["launchNpc"].GetString();			addDataToQuestsData(data);		}	} while (0);}
开发者ID:VGaer,项目名称:UnknowGameProject,代码行数:44,


示例25: JSB_glGetShaderSource

// DOMString? getShaderSource(WebGLShader? shader);JSBool JSB_glGetShaderSource(JSContext *cx, uint32_t argc, jsval *vp){    JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" );    jsval *argvp = JS_ARGV(cx,vp);    JSBool ok = JS_TRUE;    uint32_t arg0;    ok &= jsval_to_uint( cx, *argvp++, &arg0 );    JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");    GLsizei length;    glGetShaderiv(arg0, GL_SHADER_SOURCE_LENGTH, &length);    GLchar* src = new GLchar[length];    glGetShaderSource(arg0, length, NULL, src);    JS_SET_RVAL(cx, vp, charptr_to_jsval(cx, src));    CC_SAFE_DELETE_ARRAY(src);    return JS_TRUE;}
开发者ID:6520874,项目名称:pipiGame,代码行数:20,


示例26: ccDrawSolidPoly

void ccDrawSolidPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4F color ){    lazy_init();    s_pShader->use();    s_pShader->setUniformsForBuiltins();    s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &color.r, 1);    ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );    // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed    ccVertex2F* newPoli = new ccVertex2F[numberOfPoints];    // iPhone and 32-bit machines optimization    if( sizeof(CCPoint) == sizeof(ccVertex2F) )    {#ifdef EMSCRIPTEN        setGLBufferData((void*) poli, numberOfPoints * sizeof(CCPoint));        glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);#else        glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, poli);#endif // EMSCRIPTEN    }    else    {        // Mac on 64-bit        for( unsigned int i=0; i<numberOfPoints;i++)        {            newPoli[i] = vertex2( poli[i].x, poli[i].y );        }#ifdef EMSCRIPTEN        setGLBufferData(newPoli, numberOfPoints * sizeof(ccVertex2F));        glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);#else        glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoli);#endif // EMSCRIPTEN    }        glDrawArrays(GL_TRIANGLE_FAN, 0, (GLsizei) numberOfPoints);    CC_SAFE_DELETE_ARRAY(newPoli);    CC_INCREMENT_GL_DRAWS(1);}
开发者ID:1085075003,项目名称:quick-cocos2d-x,代码行数:43,


示例27: JSB_glGetShaderSource

// DOMString? getShaderSource(WebGLShader? shader);bool JSB_glGetShaderSource(JSContext *cx, uint32_t argc, jsval *vp){    JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" );    JS::CallArgs args = JS::CallArgsFromVp(argc, vp);    bool ok = true;    uint32_t arg0;    ok &= jsval_to_uint( cx, args.get(0), &arg0 );    JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");    GLsizei length;    glGetShaderiv(arg0, GL_SHADER_SOURCE_LENGTH, &length);    GLchar* src = new (std::nothrow) GLchar[length];    glGetShaderSource(arg0, length, NULL, src);    args.rval().set(charptr_to_jsval(cx, src));    CC_SAFE_DELETE_ARRAY(src);    return true;}
开发者ID:ricardperez,项目名称:Rotallector,代码行数:20,


示例28: drawSolidPoly

void drawSolidPoly(const Vec2 *poli, unsigned int numberOfPoints, Color4F color){    lazy_init();    s_shader->use();    s_shader->setUniformsForBuiltins();    s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &color.r, 1);    GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );    // FIXME: Mac OpenGL error. arrays can't go out of scope before draw is executed    Vec2* newPoli = new (std::nothrow) Vec2[numberOfPoints];    // iPhone and 32-bit machines optimization    if (sizeof(Vec2) == sizeof(Vec2))    {#ifdef EMSCRIPTEN        setGLBufferData((void*) poli, numberOfPoints * sizeof(Vec2));        glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);#else        glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli);#endif // EMSCRIPTEN    }    else    {        // Mac on 64-bit        for(unsigned int i = 0; i < numberOfPoints; i++)        {            newPoli[i] = Vec2( poli[i].x, poli[i].y );        }#ifdef EMSCRIPTEN        setGLBufferData(newPoli, numberOfPoints * sizeof(Vec2));        glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);#else        glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoli);#endif // EMSCRIPTEN    }        glDrawArrays(GL_TRIANGLE_FAN, 0, (GLsizei) numberOfPoints);    CC_SAFE_DELETE_ARRAY(newPoli);    CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, numberOfPoints);}
开发者ID:fdmjyoshi3,项目名称:cocos2d-x,代码行数:43,


示例29: ccDrawColor4B

void CPrimitiveScene::draw(){        CCCamera* pCamera = CCDirector::sharedDirector()->getRunningScene()->getCamera();    pCamera->setEyeXYZ(0,0,10);    pCamera->setCenterXYZ(-50.0f, -50.0f, 0);    // open yellow poly    ccDrawColor4B(255, 255, 0, 255);    glLineWidth(10);    ccVertex3F vertices[] = { vertex3(0,0,0), vertex3(50,50,0), vertex3(100,50,0), vertex3(100,100,0), vertex3(50,100,0.1) };            s_pShader->use();    s_pShader->setUniformForModelViewProjectionMatrix();    s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);    ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );    int numberOfPoints = 5;    // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed    ccVertex3F* newPoli = new ccVertex3F[numberOfPoints];    // iPhone and 32-bit machines optimization    if( sizeof(CCPoint) == sizeof(ccVertex3F) )    {        glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, vertices);    }    else    {        // Mac on 64-bit        for( unsigned int i=0; i<numberOfPoints;i++)        {            newPoli[i] = vertex3( vertices[i].x, vertices[i].y, vertices[i].z );        }        glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, newPoli);    }        glDrawArrays(GL_TRIANGLE_FAN, 0, (GLsizei) numberOfPoints);    CC_SAFE_DELETE_ARRAY(newPoli);    CC_INCREMENT_GL_DRAWS(1);}
开发者ID:valkidy,项目名称:homedefence,代码行数:43,



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


C++ CC_SAFE_FREE函数代码示例
C++ CC_SAFE_DELETE函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。