summaryrefslogtreecommitdiff
path: root/src/textbuf.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-11-14 22:50:17 +0000
committerfrosch <frosch@openttd.org>2012-11-14 22:50:17 +0000
commitf6d4200f86e93828a4a58a957d6ae7d9d5497a86 (patch)
tree2d940ae42f1f273a19c2c33f2858feab9122d9c2 /src/textbuf.cpp
parent0ea21523556a345d38933ee2dd6dcdca0ec08514 (diff)
downloadopenttd-f6d4200f86e93828a4a58a957d6ae7d9d5497a86.tar.xz
(svn r24738) -Codechange: Remove Textbuf::Initialize in favour of a constructor.
Diffstat (limited to 'src/textbuf.cpp')
-rw-r--r--src/textbuf.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/textbuf.cpp b/src/textbuf.cpp
index 0816c5dcf..fe32712dc 100644
--- a/src/textbuf.cpp
+++ b/src/textbuf.cpp
@@ -18,6 +18,7 @@
#include "gfx_type.h"
#include "gfx_func.h"
#include "window_func.h"
+#include "core/alloc_func.hpp"
/**
* Try to retrive the current clipboard contents.
@@ -355,29 +356,23 @@ bool Textbuf::MovePos(int navmode)
* and the maximum length of this buffer
* @param buf the buffer that will be holding the data for input
* @param max_bytes maximum size in bytes, including terminating '\0'
- */
-void Textbuf::Initialize(char *buf, uint16 max_bytes)
-{
- this->Initialize(buf, max_bytes, max_bytes);
-}
-
-/**
- * Initialize the textbuffer by supplying it the buffer to write into
- * and the maximum length of this buffer
- * @param buf the buffer that will be holding the data for input
- * @param max_bytes maximum size in bytes, including terminating '\0'
* @param max_chars maximum size in chars, including terminating '\0'
*/
-void Textbuf::Initialize(char *buf, uint16 max_bytes, uint16 max_chars)
+Textbuf::Textbuf(uint16 max_bytes, uint16 max_chars)
+ : buf(MallocT<char>(max_bytes))
{
assert(max_bytes != 0);
assert(max_chars != 0);
- this->buf = buf;
this->max_bytes = max_bytes;
- this->max_chars = max_chars;
+ this->max_chars = max_chars == UINT16_MAX ? max_bytes : max_chars;
this->caret = true;
- this->UpdateSize();
+ this->DeleteAll();
+}
+
+Textbuf::~Textbuf()
+{
+ free(this->buf);
}
/**