From 8fb895a3fa20892c65e975107e2f7d8922efea48 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Fri, 28 Oct 2011 23:29:26 +1100 Subject: Fix warnings from Clang analyze by using single statement alloc and init. Remove unused variables. Fix potential leak. --- cocoa/PlatCocoa.mm | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'cocoa/PlatCocoa.mm') diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index f65b28a52..02a000b39 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -1333,10 +1333,9 @@ static NSImage* ImageFromXPM(XPM* pxpm) SurfaceImpl* surfaceIXPM = static_cast(surfaceXPM); CGContextClearRect(surfaceIXPM->GetContext(), CGRectMake(0, 0, width, height)); pxpm->Draw(surfaceXPM, rcxpm); - img = [NSImage alloc]; + img = [[NSImage alloc] initWithSize:NSZeroSize]; [img autorelease]; CGImageRef imageRef = surfaceIXPM->GetImage(); - [img initWithSize:NSZeroSize]; NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCGImage: imageRef]; [img addRepresentation: bitmapRep]; [bitmapRep release]; @@ -1795,11 +1794,10 @@ void ListBoxImpl::RegisterImage(int type, const char* xpm_data) } void ListBoxImpl::RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) { - NSImage *img = [NSImage alloc]; - [img autorelease]; CGImageRef imageRef = ImageFromRGBA(width, height, pixelsImage, false); NSSize sz = {width, height}; - [img initWithSize: sz]; + NSImage *img = [[NSImage alloc] initWithSize: sz]; + [img autorelease]; NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCGImage: imageRef]; [img addRepresentation: bitmapRep]; [bitmapRep release]; @@ -1926,8 +1924,7 @@ void Menu::Show(Point, Window &) ElapsedTime::ElapsedTime() { struct timeval curTime; - int retVal; - retVal = gettimeofday( &curTime, NULL ); + gettimeofday( &curTime, NULL ); bigBit = curTime.tv_sec; littleBit = curTime.tv_usec; @@ -1935,8 +1932,7 @@ ElapsedTime::ElapsedTime() { double ElapsedTime::Duration(bool reset) { struct timeval curTime; - int retVal; - retVal = gettimeofday( &curTime, NULL ); + gettimeofday( &curTime, NULL ); long endBigBit = curTime.tv_sec; long endLittleBit = curTime.tv_usec; double result = 1000000.0 * (endBigBit - bigBit); -- cgit v1.2.3