summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2015-03-03 17:13:42 +0000
committerDaniel P. Berrange <berrange@redhat.com>2015-10-20 14:59:09 +0100
commit88c5f205fa4c095db4c50eb7ad72816140206819 (patch)
tree00662609c3f1e34c7814b020d75fcb0f200fa299 /ui
parent10817bf09d5f8cb22711fb0ee8d8da49f6f05f89 (diff)
downloadqemu-88c5f205fa4c095db4c50eb7ad72816140206819.tar.gz
qemu-88c5f205fa4c095db4c50eb7ad72816140206819.tar.bz2
qemu-88c5f205fa4c095db4c50eb7ad72816140206819.zip
util: pull Buffer code out of VNC module
The Buffer code in the VNC server is useful for the IO channel code, so pull it out into a shared module, QIOBuffer. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/vnc.c43
-rw-r--r--ui/vnc.h16
2 files changed, 1 insertions, 58 deletions
diff --git a/ui/vnc.c b/ui/vnc.c
index 1fa05506cc..faff0546e8 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -647,49 +647,6 @@ void vnc_framebuffer_update(VncState *vs, int x, int y, int w, int h,
vnc_write_s32(vs, encoding);
}
-void buffer_reserve(Buffer *buffer, size_t len)
-{
- if ((buffer->capacity - buffer->offset) < len) {
- buffer->capacity += (len + 1024);
- buffer->buffer = g_realloc(buffer->buffer, buffer->capacity);
- }
-}
-
-static int buffer_empty(Buffer *buffer)
-{
- return buffer->offset == 0;
-}
-
-uint8_t *buffer_end(Buffer *buffer)
-{
- return buffer->buffer + buffer->offset;
-}
-
-void buffer_reset(Buffer *buffer)
-{
- buffer->offset = 0;
-}
-
-void buffer_free(Buffer *buffer)
-{
- g_free(buffer->buffer);
- buffer->offset = 0;
- buffer->capacity = 0;
- buffer->buffer = NULL;
-}
-
-void buffer_append(Buffer *buffer, const void *data, size_t len)
-{
- memcpy(buffer->buffer + buffer->offset, data, len);
- buffer->offset += len;
-}
-
-void buffer_advance(Buffer *buf, size_t len)
-{
- memmove(buf->buffer, buf->buffer + len,
- (buf->offset - len));
- buf->offset -= len;
-}
static void vnc_desktop_resize(VncState *vs)
{
diff --git a/ui/vnc.h b/ui/vnc.h
index 4dd769cddb..2863f583aa 100644
--- a/ui/vnc.h
+++ b/ui/vnc.h
@@ -34,6 +34,7 @@
#include "audio/audio.h"
#include "qemu/bitmap.h"
#include "crypto/tlssession.h"
+#include "qemu/buffer.h"
#include <zlib.h>
#include <stdbool.h>
@@ -56,13 +57,6 @@
*
*****************************************************************************/
-typedef struct Buffer
-{
- size_t capacity;
- size_t offset;
- uint8_t *buffer;
-} Buffer;
-
typedef struct VncState VncState;
typedef struct VncJob VncJob;
typedef struct VncRect VncRect;
@@ -535,14 +529,6 @@ ssize_t vnc_client_io_error(VncState *vs, ssize_t ret, int last_errno);
void start_client_init(VncState *vs);
void start_auth_vnc(VncState *vs);
-/* Buffer management */
-void buffer_reserve(Buffer *buffer, size_t len);
-void buffer_reset(Buffer *buffer);
-void buffer_free(Buffer *buffer);
-void buffer_append(Buffer *buffer, const void *data, size_t len);
-void buffer_advance(Buffer *buf, size_t len);
-uint8_t *buffer_end(Buffer *buffer);
-
/* Misc helpers */