summaryrefslogtreecommitdiff
path: root/src/interface/Textblock.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-06-18 16:07:27 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-06-18 16:07:27 (GMT)
commit8c608ee8b9d5d4913eb3a851cfd9c6f0a87e105d (patch)
treed74a3d61d55ce7c9ab0daea371e33b0b0549300e /src/interface/Textblock.cpp
parent7ffaa421d184ef63c9e34fa80b2438d1ec670161 (diff)
downloadpowder-8c608ee8b9d5d4913eb3a851cfd9c6f0a87e105d.zip
powder-8c608ee8b9d5d4913eb3a851cfd9c6f0a87e105d.tar.gz
Use C++ allocation/freeing for text masking and multiline processing
Diffstat (limited to 'src/interface/Textblock.cpp')
-rw-r--r--src/interface/Textblock.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/interface/Textblock.cpp b/src/interface/Textblock.cpp
index c378925..f003a6a 100644
--- a/src/interface/Textblock.cpp
+++ b/src/interface/Textblock.cpp
@@ -28,8 +28,8 @@ void Textblock::SetText(std::string text)
void Textblock::updateMultiline()
{
- char * rawText = (char*)malloc(text.length()+1);
- memcpy(rawText, text.c_str(), text.length());
+ char * rawText = new char[text.length()+1];
+ std::copy(text.begin(), text.end(), rawText);
rawText[text.length()] = 0;
int lines = 1;
@@ -60,7 +60,8 @@ void Textblock::updateMultiline()
{
Size.Y = lines*12;
}
- textLines = rawText;
+ textLines = std::string(rawText);
+ delete[] rawText;
}
void Textblock::Draw(const Point &screenPos)