Bug #484
CCTextureAtlas::initWithTexture() may cause memory leak
| Status: | Closed | Start date: | 2011-05-06 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 100% |
||
| Category: | - | |||
| Target version: | - |
Description
bool CCTextureAtlas::initWithTexture(CCTexture2D *texture, unsigned int capacity)
{
assert(texture != NULL);
m_uCapacity = capacity;
m_uTotalQuads = 0;
// retained in property
this->m_pTexture = texture;
CC_SAFE_RETAIN(m_pTexture);
m_pQuads = (ccV3F_C4B_T2F_Quad*)calloc( sizeof(ccV3F_C4B_T2F_Quad) * m_uCapacity, 1 );
m_pIndices = (GLushort *)calloc( sizeof(GLushort) * 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.
History
Updated by Zhe Wang about 2 years ago
- Status changed from New to Resolved
- % Done changed from 0 to 100
Applied in changeset commit:7cd52b11452e99982379a142dd9dad771b9b7922.
Updated by Minggo Zhang about 2 years ago
Applied in changeset commit:e93c06bb70038cb577e340b6ee1aab95cb576f48.
Updated by Zhe Wang about 2 years ago
- Status changed from Resolved to Closed