aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <unknown>2001-11-06 02:22:16 +0000
committernyamatongwe <unknown>2001-11-06 02:22:16 +0000
commitcf0f4048dafeea892c526480670fbaa19d37ccd0 (patch)
tree469c83fee38e39e33e78e15dc48e209b845a3ccd /src
parentc2a06da4d2e3cb4a783451cd678e41b11f3e5ec3 (diff)
downloadscintilla-mirror-cf0f4048dafeea892c526480670fbaa19d37ccd0.tar.gz
Memory leak fixed in calltips and better casts when returning pointers.
Diffstat (limited to 'src')
-rw-r--r--src/CallTip.cxx13
-rw-r--r--src/Editor.cxx4
2 files changed, 9 insertions, 8 deletions
diff --git a/src/CallTip.cxx b/src/CallTip.cxx
index 4e075cf23..8f85e1b5c 100644
--- a/src/CallTip.cxx
+++ b/src/CallTip.cxx
@@ -118,22 +118,22 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
const char *faceName, int size) {
- Surface *surfaceMeasure=Surface::Allocate();
- if (!surfaceMeasure)
- return PRectangle();
- surfaceMeasure->Init();
- int deviceHeight = surfaceMeasure->DeviceHeightFont(size);
- font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
if (val)
delete []val;
val = new char[strlen(defn) + 1];
if (!val)
return PRectangle();
strcpy(val, defn);
+ Surface *surfaceMeasure=Surface::Allocate();
+ if (!surfaceMeasure)
+ return PRectangle();
+ surfaceMeasure->Init();
startHighlight = 0;
endHighlight = 0;
inCallTipMode = true;
posStartCallTip = pos;
+ int deviceHeight = surfaceMeasure->DeviceHeightFont(size);
+ font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
// Look for multiple lines in the text
// Only support \n here - simply means container must avoid \r!
int width = 0;
@@ -151,6 +151,7 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
int lineHeight = surfaceMeasure->Height(font);
// Extra line for border and an empty line at top and bottom
int height = lineHeight * numLines - surfaceMeasure->InternalLeading(font) + 2 + 2;
+ delete surfaceMeasure;
return PRectangle(pt.x -5, pt.y + 1, pt.x + width - 5, pt.y + 1 + height);
}
diff --git a/src/Editor.cxx b/src/Editor.cxx
index cb374cc01..ce56ee8b5 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -4625,7 +4625,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_GETDOCPOINTER:
- return reinterpret_cast<long>(pdoc);
+ return reinterpret_cast<sptr_t>(pdoc);
case SCI_SETDOCPOINTER:
SetDocPointer(reinterpret_cast<Document *>(lParam));
@@ -4634,7 +4634,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_CREATEDOCUMENT: {
Document *doc = new Document();
doc->AddRef();
- return reinterpret_cast<long>(doc);
+ return reinterpret_cast<sptr_t>(doc);
}
case SCI_ADDREFDOCUMENT: