mirror of https://github.com/axmolengine/axmol.git
Plugged CoreFoundation memory leaks identified by Static Analyzer.
This commit is contained in:
parent
9f1899978e
commit
857608495c
|
@ -235,7 +235,7 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT
|
||||||
CGContextRelease(context);
|
CGContextRelease(context);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// TODO: rename _initWithImage, it also makes a draw call.
|
||||||
static bool _initWithImage(CGImageRef CGImage, tImageInfo *pImageinfo, double scaleX, double scaleY)
|
static bool _initWithImage(CGImageRef CGImage, tImageInfo *pImageinfo, double scaleX, double scaleY)
|
||||||
{
|
{
|
||||||
NSUInteger POTWide, POTHigh;
|
NSUInteger POTWide, POTHigh;
|
||||||
|
@ -258,10 +258,8 @@ static bool _initWithImage(CGImageRef CGImage, tImageInfo *pImageinfo, double sc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// always load premultiplied images
|
// load and draw image
|
||||||
_initPremultipliedATextureWithImage(CGImage, POTWide, POTHigh, pImageinfo);
|
return _initPremultipliedATextureWithImage(CGImage, POTWide, POTHigh, pImageinfo);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _initWithFile(const char* path, tImageInfo *pImageinfo)
|
static bool _initWithFile(const char* path, tImageInfo *pImageinfo)
|
||||||
|
@ -277,17 +275,19 @@ static bool _initWithFile(const char* path, tImageInfo *pImageinfo)
|
||||||
jpg = [[NSImage alloc] initWithContentsOfFile: fullPath];
|
jpg = [[NSImage alloc] initWithContentsOfFile: fullPath];
|
||||||
//png = [[NSImage alloc] initWithData:UIImagePNGRepresentation(jpg)];
|
//png = [[NSImage alloc] initWithData:UIImagePNGRepresentation(jpg)];
|
||||||
CGImageSourceRef source = CGImageSourceCreateWithData((CFDataRef)[jpg TIFFRepresentation], NULL);
|
CGImageSourceRef source = CGImageSourceCreateWithData((CFDataRef)[jpg TIFFRepresentation], NULL);
|
||||||
CGImage = CGImageSourceCreateImageAtIndex(source, 0, NULL);
|
CGImage = CGImageSourceCreateImageAtIndex(source, 0, NULL);
|
||||||
|
|
||||||
ret = _initWithImage(CGImage, pImageinfo, 1.0, 1.0);
|
ret = _initWithImage(CGImage, pImageinfo, 1.0, 1.0);
|
||||||
|
|
||||||
//[png release];
|
//[png release];
|
||||||
[jpg release];
|
[jpg release];
|
||||||
|
if (CGImage) CFRelease(CGImage);
|
||||||
|
if (source) CFRelease(source);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: rename _initWithData, it also makes a draw call.
|
||||||
static bool _initWithData(void * pBuffer, int length, tImageInfo *pImageinfo, double scaleX, double scaleY)
|
static bool _initWithData(void * pBuffer, int length, tImageInfo *pImageinfo, double scaleX, double scaleY)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
@ -302,8 +302,9 @@ static bool _initWithData(void * pBuffer, int length, tImageInfo *pImageinfo, do
|
||||||
CGImage = CGImageSourceCreateImageAtIndex(source, 0, NULL);
|
CGImage = CGImageSourceCreateImageAtIndex(source, 0, NULL);
|
||||||
|
|
||||||
ret = _initWithImage(CGImage, pImageinfo, scaleX, scaleY);
|
ret = _initWithImage(CGImage, pImageinfo, scaleX, scaleY);
|
||||||
|
if (CGImage) CFRelease(CGImage);
|
||||||
|
if (source) CFRelease(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue