aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <nyamatongwe@gmail.com>2011-10-28 23:29:26 +1100
committernyamatongwe <nyamatongwe@gmail.com>2011-10-28 23:29:26 +1100
commit8fb895a3fa20892c65e975107e2f7d8922efea48 (patch)
treea8755d99f7a46c18cd795fd0bbcd107b9a45838b
parentafaa74bd063cbd1e6e3f4f94c394d5a8a9d21192 (diff)
downloadscintilla-mirror-8fb895a3fa20892c65e975107e2f7d8922efea48.tar.gz
Fix warnings from Clang analyze by using single statement alloc and init.
Remove unused variables. Fix potential leak.
-rw-r--r--cocoa/PlatCocoa.mm14
-rw-r--r--cocoa/ScintillaCocoa.mm5
2 files changed, 7 insertions, 12 deletions
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<SurfaceImpl*>(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);
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm
index 7927652a7..eb3fbc50c 100644
--- a/cocoa/ScintillaCocoa.mm
+++ b/cocoa/ScintillaCocoa.mm
@@ -417,7 +417,7 @@ std::string ScintillaCocoa::CaseMapString(const std::string &s, int caseMapping)
sMapped = [(NSString *)cfsVal lowercaseString];
break;
default:
- sMapped = [(NSString *)cfsVal copy];
+ sMapped = (NSString *)cfsVal;
}
// Back to encoding
@@ -782,8 +782,7 @@ void ScintillaCocoa::CreateCallTipWindow(PRectangle rc) {
[callTip setLevel:NSFloatingWindowLevel];
[callTip setHasShadow:YES];
NSRect ctContent = NSMakeRect(0,0, rc.Width(), rc.Height());
- CallTipView *caption = [CallTipView alloc];
- [caption initWithFrame: ctContent];
+ CallTipView *caption = [[CallTipView alloc] initWithFrame: ctContent];
[caption setAutoresizingMask: NSViewWidthSizable | NSViewMaxYMargin];
[caption setSci: this];
[[callTip contentView] addSubview: caption];