本文整理汇总了C++中CC_SAFE_DELETE_ARRAY函数的典型用法代码示例。如果您正苦于以下问题:C++ CC_SAFE_DELETE_ARRAY函数的具体用法?C++ CC_SAFE_DELETE_ARRAY怎么用?C++ CC_SAFE_DELETE_ARRAY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CC_SAFE_DELETE_ARRAY函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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;
}
示例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;
}
示例5: 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 );
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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
}
示例10: 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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}