aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/CallTip.cxx3
-rw-r--r--src/Document.cxx2
-rw-r--r--src/Editor.cxx30
-rw-r--r--src/PositionCache.cxx2
-rw-r--r--win32/PlatWin.cxx48
-rw-r--r--win32/ScintillaWin.cxx30
6 files changed, 47 insertions, 68 deletions
diff --git a/src/CallTip.cxx b/src/CallTip.cxx
index 9f5f88476..511282eab 100644
--- a/src/CallTip.cxx
+++ b/src/CallTip.cxx
@@ -256,9 +256,8 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
clickPlace = 0;
if (val)
delete []val;
+ val = 0;
val = new char[strlen(defn) + 1];
- if (!val)
- return PRectangle();
strcpy(val, defn);
codePage = codePage_;
Surface *surfaceMeasure = Surface::Allocate();
diff --git a/src/Document.cxx b/src/Document.cxx
index 5fd2749a0..0eb511162 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -1760,8 +1760,6 @@ const char *BuiltinRegex::SubstituteByPosition(Document* doc, const char *text,
}
}
substituted = new char[lenResult + 1];
- if (!substituted)
- return 0;
char *o = substituted;
for (int j = 0; j < *length; j++) {
if (text[j] == '\\') {
diff --git a/src/Editor.cxx b/src/Editor.cxx
index ad9437a6a..6c6922648 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -5271,12 +5271,10 @@ char *Editor::CopyRange(int start, int end) {
if (start < end) {
int len = end - start;
text = new char[len + 1];
- if (text) {
- for (int i = 0; i < len; i++) {
- text[i] = pdoc->CharAt(start + i);
- }
- text[len] = '\0';
+ for (int i = 0; i < len; i++) {
+ text[i] = pdoc->CharAt(start + i);
}
+ text[len] = '\0';
}
return text;
}
@@ -6198,19 +6196,17 @@ void Editor::AddStyledText(char *buffer, int appendLength) {
// The buffer consists of alternating character bytes and style bytes
size_t textLength = appendLength / 2;
char *text = new char[textLength];
- if (text) {
- size_t i;
- for (i = 0;i < textLength;i++) {
- text[i] = buffer[i*2];
- }
- pdoc->InsertString(CurrentPosition(), text, textLength);
- for (i = 0;i < textLength;i++) {
- text[i] = buffer[i*2+1];
- }
- pdoc->StartStyling(CurrentPosition(), static_cast<char>(0xff));
- pdoc->SetStyles(textLength, text);
- delete []text;
+ size_t i;
+ for (i = 0;i < textLength;i++) {
+ text[i] = buffer[i*2];
+ }
+ pdoc->InsertString(CurrentPosition(), text, textLength);
+ for (i = 0;i < textLength;i++) {
+ text[i] = buffer[i*2+1];
}
+ pdoc->StartStyling(CurrentPosition(), static_cast<char>(0xff));
+ pdoc->SetStyles(textLength, text);
+ delete []text;
SetEmptySelection(sel.MainCaret() + textLength);
}
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index 42f5fa3f3..d3e19d4f4 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -131,8 +131,6 @@ void LineLayout::SetLineStart(int line, int start) {
if ((line >= lenLineStarts) && (line != 0)) {
int newMaxLines = line + 20;
int *newLineStarts = new int[newMaxLines];
- if (!newLineStarts)
- return;
for (int i = 0; i < newMaxLines; i++) {
if (i < lenLineStarts)
newLineStarts[i] = lineStarts[i];
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 54eb5e3cc..fefd523a1 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -1555,36 +1555,34 @@ void ListBoxX::SetList(const char *list, char separator, char typesep) {
Clear();
int size = strlen(list) + 1;
char *words = new char[size];
- if (words) {
- lti.SetWords(words);
- memcpy(words, list, size);
- char *startword = words;
- char *numword = NULL;
- int i = 0;
- for (; words[i]; i++) {
- if (words[i] == separator) {
- words[i] = '\0';
- if (numword)
- *numword = '\0';
- AppendListItem(startword, numword);
- startword = words + i + 1;
- numword = NULL;
- } else if (words[i] == typesep) {
- numword = words + i;
- }
- }
- if (startword) {
+ lti.SetWords(words);
+ memcpy(words, list, size);
+ char *startword = words;
+ char *numword = NULL;
+ int i = 0;
+ for (; words[i]; i++) {
+ if (words[i] == separator) {
+ words[i] = '\0';
if (numword)
*numword = '\0';
AppendListItem(startword, numword);
+ startword = words + i + 1;
+ numword = NULL;
+ } else if (words[i] == typesep) {
+ numword = words + i;
}
+ }
+ if (startword) {
+ if (numword)
+ *numword = '\0';
+ AppendListItem(startword, numword);
+ }
- // Finally populate the listbox itself with the correct number of items
- int count = lti.Count();
- ::SendMessage(lb, LB_INITSTORAGE, count, 0);
- for (int j=0; j<count; j++) {
- ::SendMessage(lb, LB_ADDSTRING, 0, j+1);
- }
+ // Finally populate the listbox itself with the correct number of items
+ int count = lti.Count();
+ ::SendMessage(lb, LB_INITSTORAGE, count, 0);
+ for (int j=0; j<count; j++) {
+ ::SendMessage(lb, LB_ADDSTRING, 0, j+1);
}
SetRedraw(true);
}
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 1699b769f..e8ad20ef8 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -1375,9 +1375,7 @@ void ScintillaWin::Paste() {
unsigned int bytes = memUSelection.Size();
len = UTF8Length(uptr, bytes / 2);
putf = new char[len + 1];
- if (putf) {
- UTF8FromUTF16(uptr, bytes / 2, putf, len);
- }
+ UTF8FromUTF16(uptr, bytes / 2, putf, len);
} else {
// CF_UNICODETEXT available, but not in Unicode mode
// Convert from Unicode to current Scintilla code page
@@ -1386,16 +1384,12 @@ void ScintillaWin::Paste() {
len = ::WideCharToMultiByte(cpDest, 0, uptr, -1,
NULL, 0, NULL, NULL) - 1; // subtract 0 terminator
putf = new char[len + 1];
- if (putf) {
- ::WideCharToMultiByte(cpDest, 0, uptr, -1,
+ ::WideCharToMultiByte(cpDest, 0, uptr, -1,
putf, len + 1, NULL, NULL);
- }
}
- if (putf) {
- InsertPasteText(putf, len, selStart, isRectangular, isLine);
- delete []putf;
- }
+ InsertPasteText(putf, len, selStart, isRectangular, isLine);
+ delete []putf;
}
memUSelection.Unlock();
} else {
@@ -2209,10 +2203,8 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState,
// Convert UTF-16 to UTF-8
int dataLen = UTF8Length(udata, tlen/2);
data = new char[dataLen+1];
- if (data) {
- UTF8FromUTF16(udata, tlen/2, data, dataLen);
- dataAllocated = true;
- }
+ UTF8FromUTF16(udata, tlen/2, data, dataLen);
+ dataAllocated = true;
} else {
// Convert UTF-16 to ANSI
//
@@ -2224,12 +2216,10 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState,
int tlen = ::WideCharToMultiByte(cpDest, 0, udata, -1,
NULL, 0, NULL, NULL) - 1; // subtract 0 terminator
data = new char[tlen + 1];
- if (data) {
- memset(data, 0, (tlen+1));
- ::WideCharToMultiByte(cpDest, 0, udata, -1,
- data, tlen + 1, NULL, NULL);
- dataAllocated = true;
- }
+ memset(data, 0, (tlen+1));
+ ::WideCharToMultiByte(cpDest, 0, udata, -1,
+ data, tlen + 1, NULL, NULL);
+ dataAllocated = true;
}
}