New issue
 Projects > cpp > Issues > Bug #484

CCTextureAtlas::initWithTexture() may cause memory leak

Bug #484 [Closed]
zhangxm 2011-05-06 01:03 . Updated almost 2 years ago

bool CCTextureAtlas::initWithTexture(CCTexture2D texture, unsigned int capacity)
{
assert;
m_uCapacity = capacity;
m_uTotalQuads = 0;
// retained in property
this->m_pTexture = texture;
CC_SAFE_RETAIN;
m_pQuads = calloc
m_uCapacity, 1 );
m_pIndices = (GLushort )calloc m_uCapacity * 6, 1 );

if( ! ( m_pQuads && m_pIndices) ) {
//CCLOG(“cocos2d: CCTextureAtlas: not enough memory”);
CC_SAFE_FREE(m_pQuads)
CC_SAFE_FREE(m_pIndices)
return false;
}

When the condition in if sentence is true, should release the texture. Because the destructure will release it, so should use CC_SAFE_RELEASE_NULL() to release it.

walzer 2011-05-08 03:00
  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Applied in changeset commit:7cd52b11452e99982379a142dd9dad771b9b7922.

zhangxm 2011-05-08 03:00

Applied in changeset commit:e93c06bb70038cb577e340b6ee1aab95cb576f48.

walzer 2011-05-08 05:53
  • Status changed from Resolved to Closed
walzer 2012-05-25 08:11
  • Project changed from cocos2d-x to cpp
  • Category deleted (5)
  • Target version deleted (cocos2d-0.99.5-x-0.8.3)

Atom PDF

Status:Closed
Start date:2011-05-06
Priority:Normal
Due date:
Assignee:zhangxm
% Done:

100%

Category:-
Target version:-

Copyright © 2010 - 2013 Cocos2d-x.orgClustrmaps