diff options
author | nyamatongwe <devnull@localhost> | 2013-05-02 13:16:36 +1000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2013-05-02 13:16:36 +1000 |
commit | 99b7137e39e76ef912a7928aa7e12b284b46b1ec (patch) | |
tree | ae0e0bcf069de6233429e68fb0bf3a4fdc16ecf6 /src | |
parent | bf3eb596d5cd6405fea1dd8aea7ab8a9038101b4 (diff) | |
download | scintilla-mirror-99b7137e39e76ef912a7928aa7e12b284b46b1ec.tar.gz |
Replacing raw pointer and allocation with std::string.
Diffstat (limited to 'src')
-rw-r--r-- | src/CallTip.cxx | 22 | ||||
-rw-r--r-- | src/CallTip.h | 2 |
2 files changed, 10 insertions, 14 deletions
diff --git a/src/CallTip.cxx b/src/CallTip.cxx index d5ba3bd09..8931f413d 100644 --- a/src/CallTip.cxx +++ b/src/CallTip.cxx @@ -7,12 +7,14 @@ #include <stdlib.h> #include <string.h> +#include <stdio.h> + +#include <string> #include "Platform.h" #include "Scintilla.h" #include "CallTip.h" -#include <stdio.h> #ifdef SCI_NAMESPACE using namespace Scintilla; @@ -22,7 +24,6 @@ CallTip::CallTip() { wCallTip = 0; inCallTipMode = false; posStartCallTip = 0; - val = 0; rectUp = PRectangle(0,0,0,0); rectDown = PRectangle(0,0,0,0); lineHeight = 1; @@ -56,8 +57,6 @@ CallTip::CallTip() { CallTip::~CallTip() { font.Release(); wCallTip.Destroy(); - delete []val; - val = 0; } // Although this test includes 0, we should never see a \0 character. @@ -176,17 +175,17 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) { // Draw the definition in three parts: before highlight, highlighted, after highlight int ytext = rcClient.top + ascent + 1; rcClient.bottom = ytext + surfaceWindow->Descent(font) + 1; - char *chunkVal = val; + const char *chunkVal = val.c_str(); bool moreChunks = true; int maxWidth = 0; while (moreChunks) { - char *chunkEnd = strchr(chunkVal, '\n'); + const char *chunkEnd = strchr(chunkVal, '\n'); if (chunkEnd == NULL) { chunkEnd = chunkVal + strlen(chunkVal); moreChunks = false; } - int chunkOffset = chunkVal - val; + int chunkOffset = chunkVal - val.c_str(); int chunkLength = chunkEnd - chunkVal; int chunkEndOffset = chunkOffset + chunkLength; int thisStartHighlight = Platform::Maximum(startHighlight, chunkOffset); @@ -215,7 +214,7 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) { } void CallTip::PaintCT(Surface *surfaceWindow) { - if (!val) + if (val.empty()) return; PRectangle rcClientPos = wCallTip.GetClientPosition(); PRectangle rcClientSize(0, 0, rcClientPos.right - rcClientPos.left, @@ -253,10 +252,7 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, int textHeight, const char * int codePage_, int characterSet, int technology, Window &wParent) { clickPlace = 0; - delete []val; - val = 0; - val = new char[strlen(defn) + 1]; - strcpy(val, defn); + val = defn; codePage = codePage_; Surface *surfaceMeasure = Surface::Allocate(technology); if (!surfaceMeasure) @@ -275,7 +271,7 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, int textHeight, const char * // Only support \n here - simply means container must avoid \r! int numLines = 1; const char *newline; - const char *look = val; + const char *look = val.c_str(); rectUp = PRectangle(0,0,0,0); rectDown = PRectangle(0,0,0,0); offsetMain = insetX; // changed to right edge of any arrows diff --git a/src/CallTip.h b/src/CallTip.h index fdc4db86f..eafaa2f2e 100644 --- a/src/CallTip.h +++ b/src/CallTip.h @@ -17,7 +17,7 @@ namespace Scintilla { class CallTip { int startHighlight; // character offset to start and... int endHighlight; // ...end of highlighted text - char *val; + std::string val; Font font; PRectangle rectUp; // rectangle of last up angle in the tip PRectangle rectDown; // rectangle of last down arrow in the tip |