summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/x11/platform.cpp26
1 files changed, 7 insertions, 19 deletions
diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
index 981bdc0b..dc0787f0 100644
--- a/client/x11/platform.cpp
+++ b/client/x11/platform.cpp
@@ -2265,28 +2265,13 @@ void Platform::path_append(std::string& path, const std::string& partial_path)
static void ensure_clipboard_data_space(uint32_t size)
{
if (size > clipboard_data_space) {
- delete clipboard_data;
- clipboard_data = NULL;
- clipboard_data = new uint8_t[size];
+ free(clipboard_data);
+ clipboard_data = (uint8_t *)malloc(size);
assert(clipboard_data);
clipboard_data_space = size;
}
}
-static void realloc_clipboard_data_space(uint32_t size)
-{
- if (size <= clipboard_data_space) {
- return;
- }
- uint32_t old_alloc = clipboard_data_space;
- clipboard_data_space = size;
- uint8_t *newbuf = new uint8_t[clipboard_data_space];
- assert(newbuf);
- memcpy(newbuf, clipboard_data, old_alloc);
- delete[] clipboard_data;
- clipboard_data = newbuf;
-}
-
static void send_selection_notify(Atom prop, int process_next_req)
{
XEvent res, *event = &next_selection_request->event;
@@ -2425,8 +2410,11 @@ static int get_selection(XEvent &event, Atom type, Atom prop, int format,
if (incr) {
if (len) {
- if (clipboard_data_size + len > clipboard_data_space)
- realloc_clipboard_data_space(clipboard_data_size + len);
+ if (clipboard_data_size + len > clipboard_data_space) {
+ clipboard_data_space = clipboard_data_size + len;
+ clipboard_data = (uint8_t *)realloc(clipboard_data, clipboard_data_space);
+ assert(clipboard_data);
+ }
memcpy(clipboard_data + clipboard_data_size, data, len);
clipboard_data_size += len;
LOG_INFO("Appended %d bytes to buffer", len);