yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
5d360b
From 4c2f805375c0dc66cdd2a30b29c03021833e02ca Mon Sep 17 00:00:00 2001
5d360b
From: "Daniel P. Berrange" <berrange@redhat.com>
5d360b
Date: Thu, 8 Feb 2018 17:50:19 +0100
5d360b
Subject: [PATCH 05/27] buffer: add buffer_move_empty
5d360b
5d360b
RH-Author: Daniel P. Berrange <berrange@redhat.com>
5d360b
Message-id: <20180208175041.5634-6-berrange@redhat.com>
5d360b
Patchwork-id: 78934
5d360b
O-Subject: [RHEL-7.5 qemu-kvm PATCH v1 05/27] buffer: add buffer_move_empty
5d360b
Bugzilla: 1527405
5d360b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
5d360b
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
5d360b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
5d360b
From: Gerd Hoffmann <kraxel@redhat.com>
5d360b
5d360b
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
5d360b
Reviewed-by: Peter Lieven <pl@kamp.de>
5d360b
Reviewed-by: Daniel Berrange <berrange@redhat.com>
5d360b
Message-id: 1446203414-4013-4-git-send-email-kraxel@redhat.com
5d360b
(cherry picked from commit 4d1eb5fdb141c9100eb82e1dc7d4547fb1decd8b)
5d360b
5d360b
 Conflicts:
5d360b
	include/qemu/buffer.h
5d360b
	util/buffer.c - APIs are still in vnc.{c,h}
5d360b
5d360b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
---
5d360b
 ui/vnc.c | 15 +++++++++++++++
5d360b
 ui/vnc.h |  1 +
5d360b
 2 files changed, 16 insertions(+)
5d360b
5d360b
diff --git a/ui/vnc.c b/ui/vnc.c
5d360b
index 9047862..b520f58 100644
5d360b
--- a/ui/vnc.c
5d360b
+++ b/ui/vnc.c
5d360b
@@ -516,6 +516,21 @@ void buffer_advance(Buffer *buf, size_t len)
5d360b
     buf->offset -= len;
5d360b
 }
5d360b
 
5d360b
+void buffer_move_empty(Buffer *to, Buffer *from)
5d360b
+{
5d360b
+    assert(to->offset == 0);
5d360b
+
5d360b
+    g_free(to->buffer);
5d360b
+    to->offset = from->offset;
5d360b
+    to->capacity = from->capacity;
5d360b
+    to->buffer = from->buffer;
5d360b
+
5d360b
+    from->offset = 0;
5d360b
+    from->capacity = 0;
5d360b
+    from->buffer = NULL;
5d360b
+}
5d360b
+
5d360b
+
5d360b
 static void vnc_desktop_resize(VncState *vs)
5d360b
 {
5d360b
     if (vs->csock == -1 || !vnc_has_feature(vs, VNC_FEATURE_RESIZE)) {
5d360b
diff --git a/ui/vnc.h b/ui/vnc.h
5d360b
index d1badbb..c300660 100644
5d360b
--- a/ui/vnc.h
5d360b
+++ b/ui/vnc.h
5d360b
@@ -548,6 +548,7 @@ void buffer_free(Buffer *buffer);
5d360b
 void buffer_append(Buffer *buffer, const void *data, size_t len);
5d360b
 void buffer_advance(Buffer *buf, size_t len);
5d360b
 uint8_t *buffer_end(Buffer *buffer);
5d360b
+void buffer_move_empty(Buffer *to, Buffer *from);
5d360b
 
5d360b
 
5d360b
 /* Misc helpers */
5d360b
-- 
5d360b
1.8.3.1
5d360b