summaryrefslogtreecommitdiff
path: root/src/textbuf.cpp
diff options
context:
space:
mode:
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);
}
/**