[Spice-commits] 2 commits - NEWS server/cursor-channel.c server/dcc.c server/dcc-encoders.c server/dcc-encoders.h server/red-replay-qxl.c
Frediano Ziglio
fziglio at kemper.freedesktop.org
Thu Jan 14 08:39:52 PST 2016
NEWS | 2 --
server/cursor-channel.c | 4 ++--
server/dcc-encoders.c | 22 ++++++++--------------
server/dcc-encoders.h | 4 +---
server/dcc.c | 31 ++++++-------------------------
server/red-replay-qxl.c | 4 ++--
6 files changed, 19 insertions(+), 48 deletions(-)
New commits:
commit 5a603f2b63a276b27db254c156b0685ea52f5e52
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Thu Jan 14 17:08:18 2016 +0100
Remove GSlice use
It's being slowly deprecated in glib
https://bugzilla.gnome.org/show_bug.cgi?id=754687
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/NEWS b/NEWS
index 3b32b5c..e906e88 100644
--- a/NEWS
+++ b/NEWS
@@ -9,8 +9,6 @@ keep the code as functional as 0.12, but regressions or bugs could still happen.
* Start of a large code rework to attempt to make the codebase more
maintainable. With this first release, the huge red_worker.c file has been split
in multiple smaller files.
-* glib's GSlice is now used in some places, G_SLICE=(debug_blocks|always_malloc) may
- be needed in order to debug some memory issues.
* Added public spice_server_set_keepalive_timeout() to make it possible
to tweak keepalive on all SPICE connection. This can prevent unwanted
diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index ec994e3..4c15582 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -95,7 +95,7 @@ static CursorItem *cursor_item_new(QXLInstance *qxl, RedCursorCmd *cmd, uint32_t
spice_return_val_if_fail(cmd != NULL, NULL);
- cursor_item = g_slice_new0(CursorItem);
+ cursor_item = g_new0(CursorItem, 1);
cursor_item->qxl = qxl;
cursor_item->refs = 1;
cursor_item->group_id = group_id;
@@ -131,7 +131,7 @@ static void cursor_item_unref(CursorItem *item)
red_put_cursor_cmd(cursor_cmd);
free(cursor_cmd);
- g_slice_free(CursorItem, item);
+ g_free(item);
}
diff --git a/server/red-replay-qxl.c b/server/red-replay-qxl.c
index 95a9fdd..8e0b28c 100644
--- a/server/red-replay-qxl.c
+++ b/server/red-replay-qxl.c
@@ -1134,7 +1134,7 @@ SPICE_GNUC_VISIBLE QXLCommandExt* spice_replay_next_cmd(SpiceReplay *replay,
replay_handle_dev_input(worker, replay, type);
}
}
- cmd = g_slice_new(QXLCommandExt);
+ cmd = g_new(QXLCommandExt, 1);
cmd->cmd.type = type;
cmd->group_id = 0;
spice_debug("command %"PRIu64", %d\r", timestamp, cmd->cmd.type);
@@ -1195,7 +1195,7 @@ SPICE_GNUC_VISIBLE void spice_replay_free_cmd(SpiceReplay *replay, QXLCommandExt
break;
}
- g_slice_free(QXLCommandExt, cmd);
+ g_free(cmd);
}
/* caller is incharge of closing the replay when done and releasing the SpiceReplay
commit 400a5d13cff644369930a9c8519e288465ccab4e
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Thu Jan 14 17:08:19 2016 +0100
Remove compress_buf_new
This commit reworks a bit the management of RedCompressBuf so that
compress_buf_new/compress_buf_free become unneeded.
Since d25d6ca0 and the introduction of encoder_data_reset,
compress_buf_free is already unused outside of dcc-encoders.c and could
be static. This in turn makes compress_buf_new a bit odd as the matching
destructor is never used in dcc.c.
This commit introduces an encoder_data_init() method which is hiding
the initialization of the EncoderData structure from the dcc.c code,
allowing to get rid of compress_buf_new() calls from dcc.c code.
It also uses this as an opportunity to stop using GSlice for
RedCompressBuf.
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
index 26f3070..0923c9c 100644
--- a/server/dcc-encoders.c
+++ b/server/dcc-encoders.c
@@ -136,18 +136,12 @@ static void glz_usr_free(GlzEncoderUsrContext *usr, void *ptr)
free(ptr);
}
-RedCompressBuf* compress_buf_new(void)
+void encoder_data_init(EncoderData *data, DisplayChannelClient *dcc)
{
- RedCompressBuf *buf = g_slice_new(RedCompressBuf);
-
- buf->send_next = NULL;
-
- return buf;
-}
-
-void compress_buf_free(RedCompressBuf *buf)
-{
- g_slice_free(RedCompressBuf, buf);
+ data->bufs_tail = g_new(RedCompressBuf, 1);
+ data->bufs_head = data->bufs_tail;
+ data->dcc = dcc;
+ data->bufs_head->send_next = NULL;
}
void encoder_data_reset(EncoderData *data)
@@ -155,7 +149,7 @@ void encoder_data_reset(EncoderData *data)
RedCompressBuf *buf = data->bufs_head;
while (buf) {
RedCompressBuf *next = buf->send_next;
- compress_buf_free(buf);
+ g_free(buf);
buf = next;
}
data->bufs_head = data->bufs_tail = NULL;
@@ -168,7 +162,7 @@ static int encoder_usr_more_space(EncoderData *enc_data, uint8_t **io_ptr)
{
RedCompressBuf *buf;
- buf = compress_buf_new();
+ buf = g_new(RedCompressBuf, 1);
enc_data->bufs_tail->send_next = buf;
enc_data->bufs_tail = buf;
buf->send_next = NULL;
@@ -435,7 +429,7 @@ void dcc_encoders_free(DisplayChannelClient *dcc)
static void marshaller_compress_buf_free(uint8_t *data, void *opaque)
{
- compress_buf_free((RedCompressBuf *) opaque);
+ g_free(opaque);
}
void marshaller_add_compressed(SpiceMarshaller *m,
diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h
index 7046f1c..a244c94 100644
--- a/server/dcc-encoders.h
+++ b/server/dcc-encoders.h
@@ -51,9 +51,6 @@ void marshaller_add_compressed (SpiceMarshaller *m
RedCompressBuf *comp_buf,
size_t size);
-RedCompressBuf* compress_buf_new (void);
-void compress_buf_free (RedCompressBuf *buf);
-
#define RED_COMPRESS_BUF_SIZE (1024 * 64)
struct RedCompressBuf {
/* This buffer provide space for compression algorithms.
@@ -103,6 +100,7 @@ typedef struct {
char message_buf[512];
} EncoderData;
+void encoder_data_init(EncoderData *data, DisplayChannelClient *dcc);
void encoder_data_reset(EncoderData *data);
typedef struct {
diff --git a/server/dcc.c b/server/dcc.c
index eb5e4d1..2568e24 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -662,9 +662,7 @@ int dcc_compress_image_glz(DisplayChannelClient *dcc,
int glz_size;
int zlib_size;
- glz_data->data.bufs_tail = compress_buf_new();
- glz_data->data.bufs_head = glz_data->data.bufs_tail;
- glz_data->data.dcc = dcc;
+ encoder_data_init(&glz_data->data, dcc);
glz_drawable = get_glz_drawable(dcc, drawable);
glz_drawable_instance = add_glz_drawable_instance(glz_drawable);
@@ -689,9 +687,7 @@ int dcc_compress_image_glz(DisplayChannelClient *dcc,
stat_start_time_init(&start_time, &display_channel->zlib_glz_stat);
zlib_data = &dcc->zlib_data;
- zlib_data->data.bufs_tail = compress_buf_new();
- zlib_data->data.bufs_head = zlib_data->data.bufs_tail;
- zlib_data->data.dcc = dcc;
+ encoder_data_init(&zlib_data->data, dcc);
zlib_data->data.u.compressed_data.next = glz_data->data.bufs_head;
zlib_data->data.u.compressed_data.size_left = glz_size;
@@ -739,9 +735,7 @@ int dcc_compress_image_lz(DisplayChannelClient *dcc,
stat_start_time_t start_time;
stat_start_time_init(&start_time, &DCC_TO_DC(dcc)->lz_stat);
- lz_data->data.bufs_tail = compress_buf_new();
- lz_data->data.bufs_head = lz_data->data.bufs_tail;
- lz_data->data.dcc = dcc;
+ encoder_data_init(&lz_data->data, dcc);
if (setjmp(lz_data->data.jmp_env)) {
encoder_data_reset(&lz_data->data);
@@ -828,9 +822,7 @@ int dcc_compress_image_jpeg(DisplayChannelClient *dcc, SpiceImage *dest,
return FALSE;
}
- jpeg_data->data.bufs_tail = compress_buf_new();
- jpeg_data->data.bufs_head = jpeg_data->data.bufs_tail;
- jpeg_data->data.dcc = dcc;
+ encoder_data_init(&jpeg_data->data, dcc);
if (setjmp(jpeg_data->data.jmp_env)) {
encoder_data_reset(&jpeg_data->data);
@@ -928,16 +920,7 @@ int dcc_compress_image_lz4(DisplayChannelClient *dcc, SpiceImage *dest,
stat_start_time_t start_time;
stat_start_time_init(&start_time, &DCC_TO_DC(dcc)->lz4_stat);
- lz4_data->data.bufs_tail = compress_buf_new();
- lz4_data->data.bufs_head = lz4_data->data.bufs_tail;
-
- if (!lz4_data->data.bufs_head) {
- spice_warning("failed to allocate compress buffer");
- return FALSE;
- }
-
- lz4_data->data.bufs_head->send_next = NULL;
- lz4_data->data.dcc = dcc;
+ encoder_data_init(&lz4_data->data, dcc);
if (setjmp(lz4_data->data.jmp_env)) {
encoder_data_reset(&lz4_data->data);
@@ -1002,9 +985,7 @@ int dcc_compress_image_quic(DisplayChannelClient *dcc, SpiceImage *dest,
return FALSE;
}
- quic_data->data.bufs_tail = compress_buf_new();
- quic_data->data.bufs_head = quic_data->data.bufs_tail;
- quic_data->data.dcc = dcc;
+ encoder_data_init(&quic_data->data, dcc);
if (setjmp(quic_data->data.jmp_env)) {
encoder_data_reset(&quic_data->data);
More information about the Spice-commits
mailing list