[Spice-commits] 23 commits - server/cache-item.tmpl.c server/char-device.c server/cursor-channel.c server/dcc.c server/dispatcher.c server/display-channel.c server/event-loop.c server/gstreamer-encoder.c server/image-cache.c server/inputs-channel.c server/lz4-encoder.c server/main-channel-client.c server/mjpeg-encoder.c server/pixmap-cache.c server/red-channel-client.c server/red-channel.c server/red-parse-qxl.c server/red-pipe-item.c server/red-replay-qxl.c server/red-worker.c server/reds-stream.c server/reds.c server/smartcard-channel-client.c server/smartcard.c server/spicevmc.c server/stream.c server/tree.c
Frediano Ziglio
fziglio at kemper.freedesktop.org
Wed Oct 11 11:55:29 UTC 2017
server/cache-item.tmpl.c | 6 ++--
server/char-device.c | 12 ++++-----
server/cursor-channel.c | 2 -
server/dcc.c | 40 +++++++++++++++----------------
server/dispatcher.c | 4 +--
server/display-channel.c | 6 ++--
server/event-loop.c | 8 +++---
server/gstreamer-encoder.c | 16 ++++++------
server/image-cache.c | 4 +--
server/inputs-channel.c | 10 +++----
server/lz4-encoder.c | 8 +++---
server/main-channel-client.c | 14 +++++------
server/mjpeg-encoder.c | 28 +++++++++++-----------
server/pixmap-cache.c | 6 ++--
server/red-channel-client.c | 8 +++---
server/red-channel.c | 2 -
server/red-parse-qxl.c | 46 ++++++++++++++++++------------------
server/red-pipe-item.c | 2 -
server/red-replay-qxl.c | 48 +++++++++++++++++++-------------------
server/red-worker.c | 8 +++---
server/reds-stream.c | 39 +++++++++++-------------------
server/reds.c | 14 +++++------
server/smartcard-channel-client.c | 2 -
server/smartcard.c | 14 +++++------
server/spicevmc.c | 24 +++++++++----------
server/stream.c | 8 +++---
server/tree.c | 8 +++---
27 files changed, 189 insertions(+), 198 deletions(-)
New commits:
commit dd51cef7480959a8950fdfab6651073434a2e216
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Wed Sep 13 12:11:49 2017 +0100
red-pipe-item: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/cache-item.tmpl.c b/server/cache-item.tmpl.c
index 19e6b95f..44b45f81 100644
--- a/server/cache-item.tmpl.c
+++ b/server/cache-item.tmpl.c
@@ -86,7 +86,7 @@ static int FUNC_NAME(add)(CHANNELCLIENT *channel_client, uint64_t id, size_t siz
RedCacheItem *item;
int key;
- item = spice_new(RedCacheItem, 1);
+ item = g_new(RedCacheItem, 1);
channel_client->priv->VAR_NAME(available) -= size;
SPICE_VERIFY(SPICE_OFFSETOF(RedCacheItem, u.cache_data.lru_link) == 0);
@@ -94,7 +94,7 @@ static int FUNC_NAME(add)(CHANNELCLIENT *channel_client, uint64_t id, size_t siz
RedCacheItem *tail = (RedCacheItem *)ring_get_tail(&channel_client->priv->VAR_NAME(lru));
if (!tail) {
channel_client->priv->VAR_NAME(available) += size;
- free(item);
+ g_free(item);
return FALSE;
}
FUNC_NAME(remove)(channel_client, tail);
@@ -117,7 +117,7 @@ static void FUNC_NAME(reset)(CHANNELCLIENT *channel_client, long size)
while (channel_client->priv->CACHE_NAME[i]) {
RedCacheItem *item = channel_client->priv->CACHE_NAME[i];
channel_client->priv->CACHE_NAME[i] = item->u.cache_data.next;
- free(item);
+ g_free(item);
}
}
ring_init(&channel_client->priv->VAR_NAME(lru));
diff --git a/server/dcc.c b/server/dcc.c
index f3d53051..90684e17 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -194,7 +194,7 @@ static RedSurfaceCreateItem *red_surface_create_item_new(RedChannel* channel,
{
RedSurfaceCreateItem *create;
- create = spice_new(RedSurfaceCreateItem, 1);
+ create = g_new(RedSurfaceCreateItem, 1);
create->surface_create.surface_id = surface_id;
create->surface_create.width = width;
@@ -340,7 +340,7 @@ RedImageItem *dcc_add_surface_area_image(DisplayChannelClient *dcc,
bpp = SPICE_SURFACE_FMT_DEPTH(surface->context.format) / 8;
stride = width * bpp;
- item = (RedImageItem *)spice_malloc_n_m(height, stride, sizeof(RedImageItem));
+ item = (RedImageItem *)g_malloc(height * stride + sizeof(RedImageItem));
red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_IMAGE);
@@ -689,7 +689,7 @@ static RedSurfaceDestroyItem *red_surface_destroy_item_new(RedChannel *channel,
{
RedSurfaceDestroyItem *destroy;
- destroy = spice_new(RedSurfaceDestroyItem, 1);
+ destroy = g_new(RedSurfaceDestroyItem, 1);
destroy->surface_destroy.surface_id = surface_id;
red_pipe_item_init(&destroy->pipe_item, RED_PIPE_ITEM_TYPE_DESTROY_SURFACE);
@@ -708,7 +708,7 @@ RedPipeItem *dcc_gl_scanout_item_new(RedChannelClient *rcc, void *data, int num)
return NULL;
}
- item = spice_new(RedGlScanoutUnixItem, 1);
+ item = g_new(RedGlScanoutUnixItem, 1);
red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_GL_SCANOUT);
return &item->base;
@@ -728,7 +728,7 @@ RedPipeItem *dcc_gl_draw_item_new(RedChannelClient *rcc, void *data, int num)
}
dcc->priv->gl_draw_ongoing = TRUE;
- item = spice_new(RedGlDrawItem, 1);
+ item = g_new(RedGlDrawItem, 1);
item->draw = *draw;
red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_GL_DRAW);
diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index b8944cb0..96fd8739 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -196,7 +196,7 @@ static uint8_t kbd_get_leds(SpiceKbdInstance *sin)
static RedPipeItem *red_inputs_key_modifiers_item_new(uint8_t modifiers)
{
- RedKeyModifiersPipeItem *item = spice_malloc(sizeof(RedKeyModifiersPipeItem));
+ RedKeyModifiersPipeItem *item = g_new(RedKeyModifiersPipeItem, 1);
red_pipe_item_init(&item->base, RED_PIPE_ITEM_KEY_MODIFIERS);
item->modifiers = modifiers;
@@ -435,7 +435,7 @@ void inputs_release_keys(InputsChannel *inputs)
static void inputs_pipe_add_init(RedChannelClient *rcc)
{
- RedInputsInitPipeItem *item = spice_malloc(sizeof(RedInputsInitPipeItem));
+ RedInputsInitPipeItem *item = g_new(RedInputsInitPipeItem, 1);
InputsChannel *inputs = INPUTS_CHANNEL(red_channel_client_get_channel(rcc));
red_pipe_item_init(&item->base, RED_PIPE_ITEM_INPUTS_INIT);
diff --git a/server/main-channel-client.c b/server/main-channel-client.c
index b7b60edd..bdcc1e82 100644
--- a/server/main-channel-client.c
+++ b/server/main-channel-client.c
@@ -274,7 +274,7 @@ void main_channel_client_start_net_test(MainChannelClient *mcc, int test_rate)
static RedPipeItem *red_ping_item_new(int size)
{
- RedPingPipeItem *item = spice_malloc(sizeof(RedPingPipeItem));
+ RedPingPipeItem *item = g_new(RedPingPipeItem, 1);
red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_MAIN_PING);
item->size = size;
@@ -295,7 +295,7 @@ static bool main_channel_client_push_ping(MainChannelClient *mcc, int size)
static RedPipeItem *main_agent_tokens_item_new(uint32_t num_tokens)
{
- RedTokensPipeItem *item = spice_malloc(sizeof(RedTokensPipeItem));
+ RedTokensPipeItem *item = g_new(RedTokensPipeItem, 1);
red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_MAIN_AGENT_TOKEN);
item->tokens = num_tokens;
@@ -348,7 +348,7 @@ static RedPipeItem *main_init_item_new(int connection_id,
int multi_media_time,
int ram_hint)
{
- RedInitPipeItem *item = spice_malloc(sizeof(RedInitPipeItem));
+ RedInitPipeItem *item = g_new(RedInitPipeItem, 1);
red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_MAIN_INIT);
item->connection_id = connection_id;
@@ -377,7 +377,7 @@ void main_channel_client_push_init(MainChannelClient *mcc,
static RedPipeItem *main_name_item_new(const char *name)
{
- RedNamePipeItem *item = spice_malloc(sizeof(RedNamePipeItem) + strlen(name) + 1);
+ RedNamePipeItem *item = g_malloc(sizeof(RedNamePipeItem) + strlen(name) + 1);
red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_MAIN_NAME);
item->msg.name_len = strlen(name) + 1;
@@ -400,7 +400,7 @@ void main_channel_client_push_name(MainChannelClient *mcc, const char *name)
static RedPipeItem *main_uuid_item_new(const uint8_t uuid[16])
{
- RedUuidPipeItem *item = spice_malloc(sizeof(RedUuidPipeItem));
+ RedUuidPipeItem *item = g_new(RedUuidPipeItem, 1);
red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_MAIN_UUID);
memcpy(item->msg.uuid, uuid, sizeof(item->msg.uuid));
@@ -428,7 +428,7 @@ void main_channel_client_push_notify(MainChannelClient *mcc, const char *msg)
RedPipeItem *main_mouse_mode_item_new(SpiceMouseMode current_mode, int is_client_mouse_allowed)
{
- RedMouseModePipeItem *item = spice_malloc(sizeof(RedMouseModePipeItem));
+ RedMouseModePipeItem *item = g_new(RedMouseModePipeItem, 1);
red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_MAIN_MOUSE_MODE);
item->current_mode = current_mode;
@@ -440,7 +440,7 @@ RedPipeItem *main_multi_media_time_item_new(uint32_t mm_time)
{
RedMultiMediaTimePipeItem *item;
- item = spice_malloc(sizeof(RedMultiMediaTimePipeItem));
+ item = g_new(RedMultiMediaTimePipeItem, 1);
red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_MAIN_MULTI_MEDIA_TIME);
item->time = mm_time;
return &item->base;
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index a707dbcb..bd14be32 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -1612,7 +1612,7 @@ void red_channel_client_pipe_add_tail(RedChannelClient *rcc,
void red_channel_client_pipe_add_type(RedChannelClient *rcc, int pipe_item_type)
{
- RedPipeItem *item = spice_new(RedPipeItem, 1);
+ RedPipeItem *item = g_new(RedPipeItem, 1);
red_pipe_item_init(item, pipe_item_type);
red_channel_client_pipe_add(rcc, item);
@@ -1620,7 +1620,7 @@ void red_channel_client_pipe_add_type(RedChannelClient *rcc, int pipe_item_type)
RedPipeItem *red_channel_client_new_empty_msg(int msg_type)
{
- RedEmptyMsgPipeItem *item = spice_new(RedEmptyMsgPipeItem, 1);
+ RedEmptyMsgPipeItem *item = g_new(RedEmptyMsgPipeItem, 1);
red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_EMPTY_MSG);
item->msg = msg_type;
@@ -1771,7 +1771,7 @@ static void marker_pipe_item_free(RedPipeItem *base)
if (item->item_in_pipe) {
*item->item_in_pipe = FALSE;
}
- free(item);
+ g_free(item);
}
/* TODO: more evil sync stuff. anything with the word wait in it's name. */
@@ -1790,7 +1790,7 @@ bool red_channel_client_wait_pipe_item_sent(RedChannelClient *rcc,
end_time = UINT64_MAX;
}
- MarkerPipeItem *mark_item = spice_new0(MarkerPipeItem, 1);
+ MarkerPipeItem *mark_item = g_new0(MarkerPipeItem, 1);
red_pipe_item_init_full(&mark_item->base, RED_PIPE_ITEM_TYPE_MARKER,
marker_pipe_item_free);
diff --git a/server/red-channel.c b/server/red-channel.c
index b5094829..9736c54b 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -443,7 +443,7 @@ void red_channel_pipes_add(RedChannel *channel, RedPipeItem *item)
void red_channel_pipes_add_type(RedChannel *channel, int pipe_item_type)
{
- RedPipeItem *item = spice_new(RedPipeItem, 1);
+ RedPipeItem *item = g_new(RedPipeItem, 1);
red_pipe_item_init(item, pipe_item_type);
diff --git a/server/red-pipe-item.c b/server/red-pipe-item.c
index 2cb58473..821b5f96 100644
--- a/server/red-pipe-item.c
+++ b/server/red-pipe-item.c
@@ -44,7 +44,7 @@ void red_pipe_item_init_full(RedPipeItem *item,
{
item->type = type;
item->refcount = 1;
- item->free_func = free_func ? free_func : (red_pipe_item_free_t *)free;
+ item->free_func = free_func ? free_func : (red_pipe_item_free_t *)g_free;
}
void marshaller_unref_pipe_item(uint8_t *data G_GNUC_UNUSED, void *opaque)
diff --git a/server/smartcard-channel-client.c b/server/smartcard-channel-client.c
index 07d451f4..b1652e76 100644
--- a/server/smartcard-channel-client.c
+++ b/server/smartcard-channel-client.c
@@ -215,7 +215,7 @@ static void smartcard_channel_client_push_error(RedChannelClient *rcc,
uint32_t reader_id,
VSCErrorCode error)
{
- RedErrorItem *error_item = spice_new0(RedErrorItem, 1);
+ RedErrorItem *error_item = g_new0(RedErrorItem, 1);
red_pipe_item_init(&error_item->base, RED_PIPE_ITEM_TYPE_ERROR);
diff --git a/server/spicevmc.c b/server/spicevmc.c
index f56f50ed..45036c47 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -351,7 +351,7 @@ static RedVmcPipeItem* try_compress_lz4(RedVmcChannel *channel, int n, RedVmcPip
/* Client doesn't have compression cap - data will not be compressed */
return NULL;
}
- msg_item_compressed = spice_new0(RedVmcPipeItem, 1);
+ msg_item_compressed = g_new0(RedVmcPipeItem, 1);
red_pipe_item_init(&msg_item_compressed->base, RED_PIPE_ITEM_TYPE_SPICEVMC_DATA);
compressed_data_count = LZ4_compress_default((char*)&msg_item->buf,
(char*)&msg_item_compressed->buf,
@@ -364,12 +364,12 @@ static RedVmcPipeItem* try_compress_lz4(RedVmcChannel *channel, int n, RedVmcPip
msg_item_compressed->type = SPICE_DATA_COMPRESSION_TYPE_LZ4;
msg_item_compressed->uncompressed_data_size = n;
msg_item_compressed->buf_used = compressed_data_count;
- free(msg_item);
+ g_free(msg_item);
return msg_item_compressed;
}
/* LZ4 compression failed or did non compress, fallback a non-compressed data is to be sent */
- free(msg_item_compressed);
+ g_free(msg_item_compressed);
return NULL;
}
#endif
@@ -390,7 +390,7 @@ static RedPipeItem *spicevmc_chardev_read_msg_from_dev(RedCharDevice *self,
}
if (!channel->pipe_item) {
- msg_item = spice_new0(RedVmcPipeItem, 1);
+ msg_item = g_new0(RedVmcPipeItem, 1);
msg_item->type = SPICE_DATA_COMPRESSION_TYPE_NONE;
red_pipe_item_init(&msg_item->base, RED_PIPE_ITEM_TYPE_SPICEVMC_DATA);
} else {
@@ -455,7 +455,7 @@ static void spicevmc_port_send_init(RedChannelClient *rcc)
static void spicevmc_port_send_event(RedChannelClient *rcc, uint8_t event)
{
- RedPortEventPipeItem *item = spice_new(RedPortEventPipeItem, 1);
+ RedPortEventPipeItem *item = g_new(RedPortEventPipeItem, 1);
red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_PORT_EVENT);
item->event = event;
diff --git a/server/stream.c b/server/stream.c
index c2e82c56..846c921a 100644
--- a/server/stream.c
+++ b/server/stream.c
@@ -741,7 +741,7 @@ void dcc_create_stream(DisplayChannelClient *dcc, Stream *stream)
red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), stream_create_item_new(agent));
if (red_channel_client_test_remote_cap(RED_CHANNEL_CLIENT(dcc), SPICE_DISPLAY_CAP_STREAM_REPORT)) {
- RedStreamActivateReportItem *report_pipe_item = spice_malloc0(sizeof(*report_pipe_item));
+ RedStreamActivateReportItem *report_pipe_item = g_new0(RedStreamActivateReportItem, 1);
agent->report_id = rand();
red_pipe_item_init(&report_pipe_item->pipe_item,
commit f14ab204e5731c52ff4b763d4ab2bc946fb38011
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Wed Sep 20 08:21:46 2017 +0100
parse-qxl: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/display-channel.c b/server/display-channel.c
index f7f778ee..e91265de 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -1218,7 +1218,7 @@ static void handle_self_bitmap(DisplayChannel *display, Drawable *drawable)
height = red_drawable->self_bitmap_area.bottom - red_drawable->self_bitmap_area.top;
dest_stride = SPICE_ALIGN(width * bpp, 4);
- image = spice_new0(SpiceImage, 1);
+ image = g_new0(SpiceImage, 1);
image->descriptor.type = SPICE_IMAGE_TYPE_BITMAP;
image->descriptor.flags = 0;
diff --git a/server/red-parse-qxl.c b/server/red-parse-qxl.c
index 33f36923..9224b2c5 100644
--- a/server/red-parse-qxl.c
+++ b/server/red-parse-qxl.c
@@ -100,7 +100,7 @@ static uint8_t *red_linearize_chunk(RedDataChunk *head, size_t size, bool *free_
return head->data;
}
- ptr = data = spice_malloc(size);
+ ptr = data = g_malloc(size);
*free_chunk = true;
for (chunk = head; chunk != NULL && size > 0; chunk = chunk->next_chunk) {
copy = MIN(chunk->data_size, size);
@@ -158,7 +158,7 @@ static size_t red_get_data_chunks_ptr(RedMemSlotInfo *slots, int group_id,
continue;
red_prev = red;
- red = spice_new0(RedDataChunk, 1);
+ red = g_new0(RedDataChunk, 1);
red->data_size = chunk_data_size;
red->prev_chunk = red_prev;
red->data = qxl->data;
@@ -180,7 +180,7 @@ static size_t red_get_data_chunks_ptr(RedMemSlotInfo *slots, int group_id,
error:
while (red->prev_chunk) {
red_prev = red->prev_chunk;
- free(red);
+ g_free(red);
red = red_prev;
}
red->data_size = 0;
@@ -211,7 +211,7 @@ static void red_put_data_chunks(RedDataChunk *red)
while (red) {
tmp = red;
red = red->next_chunk;
- free(tmp);
+ g_free(tmp);
}
}
@@ -281,7 +281,7 @@ static SpicePath *red_get_path(RedMemSlotInfo *slots, int group_id,
start = (QXLPathSeg*)(&start->points[count]);
}
- red = spice_malloc(mem_size);
+ red = g_malloc(mem_size);
red->num_segments = n_segments;
start = (QXLPathSeg*)data;
@@ -312,7 +312,7 @@ static SpicePath *red_get_path(RedMemSlotInfo *slots, int group_id,
spice_assert(n_segments == red->num_segments);
if (free_data) {
- free(data);
+ g_free(data);
}
return red;
}
@@ -351,7 +351,7 @@ static SpiceClipRects *red_get_clip_rects(RedMemSlotInfo *slots, int group_id,
*/
spice_assert((uint64_t) num_rects * sizeof(QXLRect) == size);
G_STATIC_ASSERT(sizeof(SpiceRect) == sizeof(QXLRect));
- red = spice_malloc(sizeof(*red) + num_rects * sizeof(SpiceRect));
+ red = g_malloc(sizeof(*red) + num_rects * sizeof(SpiceRect));
red->num_rects = num_rects;
start = (QXLRect*)data;
@@ -360,7 +360,7 @@ static SpiceClipRects *red_get_clip_rects(RedMemSlotInfo *slots, int group_id,
}
if (free_data) {
- free(data);
+ g_free(data);
}
return red;
}
@@ -470,7 +470,7 @@ static SpiceImage *red_get_image(RedMemSlotInfo *slots, int group_id,
if (error) {
return NULL;
}
- red = spice_new0(SpiceImage, 1);
+ red = g_new0(SpiceImage, 1);
red->descriptor.id = qxl->descriptor.id;
red->descriptor.type = qxl->descriptor.type;
red->descriptor.flags = 0;
@@ -520,7 +520,7 @@ static SpiceImage *red_get_image(RedMemSlotInfo *slots, int group_id,
num_ents * sizeof(qp->ents[0]), group_id)) {
goto error;
}
- rp = spice_malloc_n_m(num_ents, sizeof(rp->ents[0]), sizeof(*rp));
+ rp = g_malloc(num_ents * sizeof(rp->ents[0]) + sizeof(*rp));
rp->unique = qp->unique;
rp->num_ents = num_ents;
if (flags & QXL_COMMAND_FLAG_COMPAT_16BPP) {
@@ -580,8 +580,8 @@ static SpiceImage *red_get_image(RedMemSlotInfo *slots, int group_id,
}
return red;
error:
- free(red);
- free(rp);
+ g_free(red);
+ g_free(rp);
return NULL;
}
@@ -592,14 +592,14 @@ static void red_put_image(SpiceImage *red)
switch (red->descriptor.type) {
case SPICE_IMAGE_TYPE_BITMAP:
- free(red->u.bitmap.palette);
+ g_free(red->u.bitmap.palette);
spice_chunks_destroy(red->u.bitmap.data);
break;
case SPICE_IMAGE_TYPE_QUIC:
spice_chunks_destroy(red->u.quic.data);
break;
}
- free(red);
+ g_free(red);
}
static void red_get_brush_ptr(RedMemSlotInfo *slots, int group_id,
@@ -839,7 +839,7 @@ static bool red_get_stroke_ptr(RedMemSlotInfo *slots, int group_id,
uint8_t *buf;
style_nseg = qxl->attr.style_nseg;
- red->attr.style = spice_malloc_n(style_nseg, sizeof(SPICE_FIXED28_4));
+ red->attr.style = g_malloc_n(style_nseg, sizeof(SPICE_FIXED28_4));
red->attr.style_nseg = style_nseg;
spice_assert(qxl->attr.style);
buf = (uint8_t *)memslot_get_virt(slots, qxl->attr.style,
@@ -861,9 +861,9 @@ static bool red_get_stroke_ptr(RedMemSlotInfo *slots, int group_id,
static void red_put_stroke(SpiceStroke *red)
{
red_put_brush(&red->brush);
- free(red->path);
+ g_free(red->path);
if (red->attr.flags & SPICE_LINE_FLAGS_STYLED) {
- free(red->attr.style);
+ g_free(red->attr.style);
}
}
@@ -930,7 +930,7 @@ static SpiceString *red_get_string(RedMemSlotInfo *slots, int group_id,
spice_assert(start <= end);
spice_assert(glyphs == qxl_length);
- red = spice_malloc(red_size);
+ red = g_malloc(red_size);
red->length = qxl_length;
red->flags = qxl_flags;
@@ -955,7 +955,7 @@ static SpiceString *red_get_string(RedMemSlotInfo *slots, int group_id,
}
if (free_data) {
- free(data);
+ g_free(data);
}
return red;
}
@@ -973,7 +973,7 @@ static void red_get_text_ptr(RedMemSlotInfo *slots, int group_id,
static void red_put_text_ptr(SpiceText *red)
{
- free(red->str);
+ g_free(red->str);
red_put_brush(&red->fore_brush);
red_put_brush(&red->back_brush);
}
@@ -1026,7 +1026,7 @@ static void red_put_clip(SpiceClip *red)
{
switch (red->type) {
case SPICE_CLIP_TYPE_RECTS:
- free(red->rects);
+ g_free(red->rects);
break;
}
}
@@ -1449,7 +1449,7 @@ static bool red_get_cursor(RedMemSlotInfo *slots, int group_id,
if (free_data) {
red->data = data;
} else {
- red->data = spice_malloc(size);
+ red->data = g_malloc(size);
memcpy(red->data, data, size);
}
return true;
@@ -1457,7 +1457,7 @@ static bool red_get_cursor(RedMemSlotInfo *slots, int group_id,
static void red_put_cursor(SpiceCursor *red)
{
- free(red->data);
+ g_free(red->data);
}
bool red_get_cursor_cmd(RedMemSlotInfo *slots, int group_id,
commit f536ca9f301c8f7d5f9d1dd3660508c4042a8333
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 23:51:20 2017 +0100
pixmap-cache: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/dcc.c b/server/dcc.c
index 1c860e82..f3d53051 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -959,7 +959,7 @@ bool dcc_pixmap_cache_unlocked_add(DisplayChannelClient *dcc, uint64_t id,
spice_assert(size > 0);
- item = spice_new(NewCacheItem, 1);
+ item = g_new(NewCacheItem, 1);
serial = red_channel_client_get_message_serial(RED_CHANNEL_CLIENT(dcc));
if (cache->generation != dcc->priv->pixmap_cache_generation) {
@@ -968,7 +968,7 @@ bool dcc_pixmap_cache_unlocked_add(DisplayChannelClient *dcc, uint64_t id,
RED_CHANNEL_CLIENT(dcc), RED_PIPE_ITEM_TYPE_PIXMAP_SYNC);
dcc->priv->pending_pixmaps_sync = TRUE;
}
- free(item);
+ g_free(item);
return FALSE;
}
@@ -981,7 +981,7 @@ bool dcc_pixmap_cache_unlocked_add(DisplayChannelClient *dcc, uint64_t id,
if (!(tail = (NewCacheItem *)ring_get_tail(&cache->lru)) ||
tail->sync[dcc->priv->id] == serial) {
cache->available += size;
- free(item);
+ g_free(item);
return FALSE;
}
@@ -999,7 +999,7 @@ bool dcc_pixmap_cache_unlocked_add(DisplayChannelClient *dcc, uint64_t id,
cache->available += tail->size;
cache->sync[dcc->priv->id] = serial;
dcc_push_release(dcc, SPICE_RES_TYPE_PIXMAP, tail->id, tail->sync);
- free(tail);
+ g_free(tail);
}
++cache->items;
item->next = cache->hash_table[(key = BITS_CACHE_HASH_KEY(id))];
diff --git a/server/pixmap-cache.c b/server/pixmap-cache.c
index f8b8a8a7..0a4b9207 100644
--- a/server/pixmap-cache.c
+++ b/server/pixmap-cache.c
@@ -49,7 +49,7 @@ void pixmap_cache_clear(PixmapCache *cache)
SPICE_VERIFY(SPICE_OFFSETOF(NewCacheItem, lru_link) == 0);
while ((item = (NewCacheItem *)ring_get_head(&cache->lru))) {
ring_remove(&item->lru_link);
- free(item);
+ g_free(item);
}
memset(cache->hash_table, 0, sizeof(*cache->hash_table) * BITS_CACHE_HASH_SIZE);
@@ -92,7 +92,7 @@ static Ring pixmap_cache_list = {&pixmap_cache_list, &pixmap_cache_list};
static PixmapCache *pixmap_cache_new(RedClient *client, uint8_t id, int64_t size)
{
- PixmapCache *cache = spice_new0(PixmapCache, 1);
+ PixmapCache *cache = g_new0(PixmapCache, 1);
ring_item_init(&cache->base);
pthread_mutex_init(&cache->lock, NULL);
@@ -143,5 +143,5 @@ void pixmap_cache_unref(PixmapCache *cache)
ring_remove(&cache->base);
pthread_mutex_unlock(&cache_lock);
pixmap_cache_destroy(cache);
- free(cache);
+ g_free(cache);
}
commit 201e4b5d78ddb87352d10aae8f8168c9aeea0b0f
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 23:50:56 2017 +0100
image-cache: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/image-cache.c b/server/image-cache.c
index bd888bef..3493ba1f 100644
--- a/server/image-cache.c
+++ b/server/image-cache.c
@@ -64,7 +64,7 @@ static void image_cache_remove(ImageCache *cache, ImageCacheItem *item)
}
ring_remove(&item->lru_link);
pixman_image_unref(item->image);
- free(item);
+ g_free(item);
#ifndef IMAGE_CACHE_AGE
cache->num_items--;
#endif
@@ -86,7 +86,7 @@ static void image_cache_put(SpiceImageCache *spice_cache, uint64_t id, pixman_im
}
#endif
- item = spice_new(ImageCacheItem, 1);
+ item = g_new(ImageCacheItem, 1);
item->id = id;
#ifdef IMAGE_CACHE_AGE
item->age = cache->age;
commit ff1d06f0f88705293962848f2f1b8bbc6c4fe819
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 23:40:43 2017 +0100
inputs-channel: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index 8e17cc72..b8944cb0 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -77,7 +77,7 @@ static SpiceTabletInstance* inputs_channel_get_tablet(InputsChannel *inputs);
static SpiceKbdState* spice_kbd_state_new(RedsState *reds)
{
- SpiceKbdState *st = spice_new0(SpiceKbdState, 1);
+ SpiceKbdState *st = g_new0(SpiceKbdState, 1);
st->reds = reds;
return st;
}
@@ -93,7 +93,7 @@ struct SpiceMouseState {
static SpiceMouseState* spice_mouse_state_new(void)
{
- return spice_new0(SpiceMouseState, 1);
+ return g_new0(SpiceMouseState, 1);
}
struct SpiceTabletState {
@@ -102,7 +102,7 @@ struct SpiceTabletState {
static SpiceTabletState* spice_tablet_state_new(void)
{
- return spice_new0(SpiceTabletState, 1);
+ return g_new0(SpiceTabletState, 1);
}
RedsState* spice_tablet_state_get_server(SpiceTabletState *st)
commit 9f4a54eb88c101b32acdb64cc828768cbce5893f
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 23:19:06 2017 +0100
tree: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/tree.c b/server/tree.c
index d47f2f59..89186a85 100644
--- a/server/tree.c
+++ b/server/tree.c
@@ -195,7 +195,7 @@ Shadow* shadow_new(DrawItem *item, const SpicePoint *delta)
return NULL;
}
- Shadow *shadow = spice_new(Shadow, 1);
+ Shadow *shadow = g_new(Shadow, 1);
shadow->base.type = TREE_ITEM_TYPE_SHADOW;
shadow->base.container = NULL;
@@ -215,7 +215,7 @@ Shadow* shadow_new(DrawItem *item, const SpicePoint *delta)
* container */
Container* container_new(DrawItem *item)
{
- Container *container = spice_new(Container, 1);
+ Container *container = g_new(Container, 1);
container->base.type = TREE_ITEM_TYPE_CONTAINER;
container->base.container = item->base.container;
@@ -237,7 +237,7 @@ void container_free(Container *container)
ring_remove(&container->base.siblings_link);
region_destroy(&container->base.rgn);
- free(container);
+ g_free(container);
}
void container_cleanup(Container *container)
@@ -308,5 +308,5 @@ void draw_item_remove_shadow(DrawItem *item)
ring_remove(&shadow->base.siblings_link);
region_destroy(&shadow->base.rgn);
region_destroy(&shadow->on_hold);
- free(shadow);
+ g_free(shadow);
}
commit 04bc835326b82cf03cad6d6fc179c1e10d5fc977
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 23:15:50 2017 +0100
worker: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index 7fab4c8c..9ae76090 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -74,7 +74,7 @@ static void cursor_pipe_item_free(RedPipeItem *base)
cursor_cmd = pipe_item->red_cursor;
red_put_cursor_cmd(cursor_cmd);
- free(cursor_cmd);
+ g_free(cursor_cmd);
g_free(pipe_item);
}
diff --git a/server/red-worker.c b/server/red-worker.c
index 8a63fde2..466a3474 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -100,16 +100,16 @@ void red_drawable_unref(RedDrawable *red_drawable)
}
red_qxl_release_resource(red_drawable->qxl, red_drawable->release_info_ext);
red_put_drawable(red_drawable);
- free(red_drawable);
+ g_free(red_drawable);
}
static gboolean red_process_cursor_cmd(RedWorker *worker, const QXLCommandExt *ext)
{
RedCursorCmd *cursor_cmd;
- cursor_cmd = spice_new0(RedCursorCmd, 1);
+ cursor_cmd = g_new0(RedCursorCmd, 1);
if (!red_get_cursor_cmd(&worker->mem_slots, ext->group_id, cursor_cmd, ext->cmd.data)) {
- free(cursor_cmd);
+ g_free(cursor_cmd);
return FALSE;
}
red_qxl_release_resource(worker->qxl, cursor_cmd->release_info_ext);
@@ -161,7 +161,7 @@ static int red_process_cursor(RedWorker *worker, int *ring_is_empty)
static RedDrawable *red_drawable_new(QXLInstance *qxl)
{
- RedDrawable * red = spice_new0(RedDrawable, 1);
+ RedDrawable * red = g_new0(RedDrawable, 1);
red->refs = 1;
red->qxl = qxl;
commit 62c8715eb5e349d8d8346d8eba075e31a3ca234d
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 23:12:03 2017 +0100
replay-qxl: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/red-replay-qxl.c b/server/red-replay-qxl.c
index 2f31e9cd..d389b62e 100644
--- a/server/red-replay-qxl.c
+++ b/server/red-replay-qxl.c
@@ -96,7 +96,7 @@ static replay_t replay_fscanf_check(SpiceReplay *replay, const char *fmt, ...)
static inline void *replay_malloc(SpiceReplay *replay, size_t size)
{
- void *mem = spice_malloc(size);
+ void *mem = g_malloc(size);
replay->allocated = g_list_prepend(replay->allocated, mem);
return mem;
}
@@ -111,13 +111,13 @@ static inline void *replay_malloc0(SpiceReplay *replay, size_t size)
static inline void replay_free(SpiceReplay *replay, void *mem)
{
replay->allocated = g_list_remove(replay->allocated, mem);
- free(mem);
+ g_free(mem);
}
static inline void *replay_realloc(SpiceReplay *replay, void *mem, size_t n_bytes)
{
GList *elem = g_list_find(replay->allocated, mem);
- elem->data = spice_realloc(mem, n_bytes);
+ elem->data = g_realloc(mem, n_bytes);
return elem->data;
}
@@ -335,11 +335,11 @@ static void red_replay_data_chunks_free(SpiceReplay *replay, void *data, size_t
cur = QXLPHYSICAL_TO_PTR(cur->next_chunk);
while (cur) {
QXLDataChunk *next = QXLPHYSICAL_TO_PTR(cur->next_chunk);
- free(cur);
+ g_free(cur);
cur = next;
}
- free(data);
+ g_free(data);
}
static void red_replay_point_ptr(SpiceReplay *replay, QXLPoint *qxl)
@@ -513,9 +513,9 @@ static void red_replay_image_free(SpiceReplay *replay, QXLPHYSICAL p, uint32_t f
switch (qxl->descriptor.type) {
case SPICE_IMAGE_TYPE_BITMAP:
- free(QXLPHYSICAL_TO_PTR(qxl->bitmap.palette));
+ g_free(QXLPHYSICAL_TO_PTR(qxl->bitmap.palette));
if (qxl->bitmap.flags & QXL_BITMAP_DIRECT) {
- free(QXLPHYSICAL_TO_PTR(qxl->bitmap.data));
+ g_free(QXLPHYSICAL_TO_PTR(qxl->bitmap.data));
} else {
red_replay_data_chunks_free(replay, QXLPHYSICAL_TO_PTR(qxl->bitmap.data), 0);
}
@@ -530,7 +530,7 @@ static void red_replay_image_free(SpiceReplay *replay, QXLPHYSICAL p, uint32_t f
spice_warn_if_reached();
}
- free(qxl);
+ g_free(qxl);
}
static void red_replay_brush_ptr(SpiceReplay *replay, QXLBrush *qxl, uint32_t flags)
@@ -722,7 +722,7 @@ static void red_replay_stroke_free(SpiceReplay *replay, QXLStroke *qxl, uint32_t
{
red_replay_path_free(replay, qxl->path);
if (qxl->attr.flags & SPICE_LINE_FLAGS_STYLED) {
- free(QXLPHYSICAL_TO_PTR(qxl->attr.style));
+ g_free(QXLPHYSICAL_TO_PTR(qxl->attr.style));
}
red_replay_brush_free(replay, &qxl->brush, flags);
}
@@ -860,9 +860,9 @@ static void red_replay_composite_ptr(SpiceReplay *replay, QXLComposite *qxl, uin
static void red_replay_composite_free(SpiceReplay *replay, QXLComposite *qxl, uint32_t flags)
{
red_replay_image_free(replay, qxl->src, flags);
- free(QXLPHYSICAL_TO_PTR(qxl->src_transform));
+ g_free(QXLPHYSICAL_TO_PTR(qxl->src_transform));
red_replay_image_free(replay, qxl->mask, flags);
- free(QXLPHYSICAL_TO_PTR(qxl->mask_transform));
+ g_free(QXLPHYSICAL_TO_PTR(qxl->mask_transform));
}
@@ -1002,7 +1002,7 @@ static void red_replay_native_drawable_free(SpiceReplay *replay, QXLDrawable *qx
break;
};
- free(qxl);
+ g_free(qxl);
}
static QXLCompatDrawable *red_replay_compat_drawable(SpiceReplay *replay, uint32_t flags)
@@ -1157,8 +1157,8 @@ static void red_replay_surface_cmd_free(SpiceReplay *replay, QXLSurfaceCmd *qxl)
replay_id_free(replay, qxl->surface_id);
}
- free(QXLPHYSICAL_TO_PTR(qxl->u.surface_create.data));
- free(qxl);
+ g_free(QXLPHYSICAL_TO_PTR(qxl->u.surface_create.data));
+ g_free(qxl);
}
static QXLCursor *red_replay_cursor(SpiceReplay *replay)
@@ -1230,7 +1230,7 @@ static void red_replay_cursor_cmd_free(SpiceReplay *replay, QXLCursorCmd *qxl)
red_replay_data_chunks_free(replay, cursor, sizeof(*cursor));
}
- free(qxl);
+ g_free(qxl);
}
static void replay_handle_create_primary(QXLWorker *worker, SpiceReplay *replay)
@@ -1256,7 +1256,7 @@ static void replay_handle_create_primary(QXLWorker *worker, SpiceReplay *replay)
}
read_binary(replay, "data", &size, &mem, 0);
surface.group_id = 0;
- free(replay->primary_mem);
+ g_free(replay->primary_mem);
replay->allocated = g_list_remove(replay->allocated, mem);
replay->primary_mem = mem;
surface.mem = QXLPHYSICAL_FROM_PTR(mem);
@@ -1274,7 +1274,7 @@ static void replay_handle_dev_input(QXLWorker *worker, SpiceReplay *replay,
case RED_WORKER_MESSAGE_DESTROY_PRIMARY_SURFACE:
replay->created_primary = FALSE;
worker->destroy_primary_surface(worker, 0);
- free(replay->primary_mem);
+ g_free(replay->primary_mem);
replay->primary_mem = NULL;
break;
case RED_WORKER_MESSAGE_DESTROY_SURFACES:
@@ -1371,7 +1371,7 @@ error:
/* if there were some allocation during the read free all
* buffers allocated to avoid leaks */
if (replay->allocated) {
- g_list_free_full(replay->allocated, free);
+ g_list_free_full(replay->allocated, g_free);
replay->allocated = NULL;
}
return NULL;
@@ -1392,7 +1392,7 @@ SPICE_GNUC_VISIBLE void spice_replay_free_cmd(SpiceReplay *replay, QXLCommandExt
}
case QXL_CMD_UPDATE: {
QXLUpdateCmd *qxl = QXLPHYSICAL_TO_PTR(cmd->cmd.data);
- free(qxl);
+ g_free(qxl);
break;
}
case QXL_CMD_SURFACE: {
@@ -1409,7 +1409,7 @@ SPICE_GNUC_VISIBLE void spice_replay_free_cmd(SpiceReplay *replay, QXLCommandExt
break;
}
- free(cmd);
+ g_free(cmd);
}
/* caller is incharge of closing the replay when done and releasing the SpiceReplay
@@ -1432,7 +1432,7 @@ SpiceReplay *spice_replay_new(FILE *file, int nsurfaces)
return NULL;
}
- replay = spice_malloc0(sizeof(SpiceReplay));
+ replay = g_new0(SpiceReplay, 1);
replay->error = FALSE;
replay->fd = file;
@@ -1455,13 +1455,13 @@ SPICE_GNUC_VISIBLE void spice_replay_free(SpiceReplay *replay)
{
spice_return_if_fail(replay != NULL);
- g_list_free_full(replay->allocated, free);
+ g_list_free_full(replay->allocated, g_free);
pthread_mutex_destroy(&replay->mutex);
pthread_cond_destroy(&replay->cond);
g_array_free(replay->id_map, TRUE);
g_array_free(replay->id_map_inv, TRUE);
g_array_free(replay->id_free, TRUE);
- free(replay->primary_mem);
+ g_free(replay->primary_mem);
fclose(replay->fd);
- free(replay);
+ g_free(replay);
}
commit 0b943afccc3b71c90a0e275df666318129758bb1
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 19:15:41 2017 +0100
display-channel: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/display-channel.c b/server/display-channel.c
index fbdca265..f7f778ee 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -170,7 +170,7 @@ void monitors_config_unref(MonitorsConfig *monitors_config)
}
spice_debug("freeing monitors config");
- free(monitors_config);
+ g_free(monitors_config);
}
static void monitors_config_debug(MonitorsConfig *mc)
@@ -188,7 +188,7 @@ static MonitorsConfig* monitors_config_new(QXLHead *heads, ssize_t nheads, ssize
{
MonitorsConfig *mc;
- mc = spice_malloc(sizeof(MonitorsConfig) + nheads * sizeof(QXLHead));
+ mc = g_malloc(sizeof(MonitorsConfig) + nheads * sizeof(QXLHead));
mc->refs = 1;
mc->count = nheads;
mc->max_allowed = max;
commit 1354ce7e68c7aa6e8a3cfb4a3d3add25a4412697
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 19:08:25 2017 +0100
dcc: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/dcc.c b/server/dcc.c
index 50101080..1c860e82 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -180,8 +180,8 @@ static void display_channel_client_init(DisplayChannelClient *self)
self->priv->encoders.jpeg_quality = 85;
self->priv->send_data.free_list.res =
- spice_malloc(sizeof(SpiceResourceList) +
- DISPLAY_FREE_LIST_DEFAULT_SIZE * sizeof(SpiceResourceID));
+ g_malloc(sizeof(SpiceResourceList) +
+ DISPLAY_FREE_LIST_DEFAULT_SIZE * sizeof(SpiceResourceID));
self->priv->send_data.free_list.res_size = DISPLAY_FREE_LIST_DEFAULT_SIZE;
}
@@ -439,7 +439,7 @@ static void red_drawable_pipe_item_free(RedPipeItem *item)
dpi->drawable->pipes = g_list_remove(dpi->drawable->pipes, dpi);
drawable_unref(dpi->drawable);
- free(dpi);
+ g_free(dpi);
}
static RedDrawablePipeItem *red_drawable_pipe_item_new(DisplayChannelClient *dcc,
@@ -447,7 +447,7 @@ static RedDrawablePipeItem *red_drawable_pipe_item_new(DisplayChannelClient *dcc
{
RedDrawablePipeItem *dpi;
- dpi = spice_malloc0(sizeof(*dpi));
+ dpi = g_new0(RedDrawablePipeItem, 1);
dpi->drawable = drawable;
dpi->dcc = dcc;
drawable->pipes = g_list_prepend(drawable->pipes, dpi);
@@ -618,7 +618,7 @@ static void dcc_stop(DisplayChannelClient *dcc)
pixmap_cache_unref(dcc->priv->pixmap_cache);
dcc->priv->pixmap_cache = NULL;
dcc_palette_cache_reset(dcc);
- free(dcc->priv->send_data.free_list.res);
+ g_free(dcc->priv->send_data.free_list.res);
dcc_destroy_stream_agents(dcc);
image_encoders_free(&dcc->priv->encoders);
@@ -647,7 +647,7 @@ static void red_monitors_config_item_free(RedPipeItem *base)
RedMonitorsConfigItem *item = SPICE_CONTAINEROF(base, RedMonitorsConfigItem, pipe_item);
monitors_config_unref(item->monitors_config);
- free(item);
+ g_free(item);
}
static RedMonitorsConfigItem *red_monitors_config_item_new(RedChannel* channel,
@@ -655,7 +655,7 @@ static RedMonitorsConfigItem *red_monitors_config_item_new(RedChannel* channel,
{
RedMonitorsConfigItem *mci;
- mci = spice_new(RedMonitorsConfigItem, 1);
+ mci = g_new(RedMonitorsConfigItem, 1);
mci->monitors_config = monitors_config_ref(monitors_config);
red_pipe_item_init_full(&mci->pipe_item, RED_PIPE_ITEM_TYPE_MONITORS_CONFIG,
@@ -940,9 +940,9 @@ static void dcc_push_release(DisplayChannelClient *dcc, uint8_t type, uint64_t i
}
if (free_list->res->count == free_list->res_size) {
- free_list->res = spice_realloc(free_list->res,
- sizeof(*free_list->res) +
- free_list->res_size * sizeof(SpiceResourceID) * 2);
+ free_list->res = g_realloc(free_list->res,
+ sizeof(*free_list->res) +
+ free_list->res_size * sizeof(SpiceResourceID) * 2);
free_list->res_size *= 2;
}
free_list->res->resources[free_list->res->count].type = type;
commit 13fffbf885ddaf15abc85c0ae3f969a842df0c91
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Wed Sep 20 08:09:45 2017 +0100
reds: Use GLib memory functions for ChannelSecurityOptions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/reds.c b/server/reds.c
index 9e62f22d..6c8e0695 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2951,7 +2951,7 @@ static void reds_set_one_channel_security(RedsState *reds, int id, uint32_t secu
security_options->options = security;
return;
}
- security_options = spice_new(ChannelSecurityOptions, 1);
+ security_options = g_new(ChannelSecurityOptions, 1);
security_options->channel_id = id;
security_options->options = security;
security_options->next = reds->config->channels_security;
@@ -3708,7 +3708,7 @@ static void reds_config_free(RedServerConfig *config)
reds_mig_release(config);
for (curr = config->channels_security; curr; curr = next) {
next = curr->next;
- free(curr);
+ g_free(curr);
}
#if HAVE_SASL
g_free(config->sasl_appname);
commit 6e2e98383f69a51c641b437f0ac3335c5b019c93
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 18:57:00 2017 +0100
reds: Use GLib memory functions for link message
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/reds.c b/server/reds.c
index 3a0fbb51..9e62f22d 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -334,7 +334,7 @@ static void reds_link_free(RedLinkInfo *link)
reds_stream_free(link->stream);
link->stream = NULL;
- free(link->link_mess);
+ g_free(link->link_mess);
link->link_mess = NULL;
BN_free(link->tiTicketing.bn);
@@ -1811,7 +1811,7 @@ static void reds_handle_main_link(RedsState *reds, RedLinkInfo *link)
&caps);
red_channel_capabilities_reset(&caps);
spice_debug("NEW Client %p mcc %p connect-id %d", client, mcc, connection_id);
- free(link_mess);
+ g_free(link_mess);
red_client_set_main(client, mcc);
if (reds->vdagent) {
@@ -2019,7 +2019,7 @@ static void reds_handle_other_links(RedsState *reds, RedLinkInfo *link)
} else {
spice_assert(!mig_client);
reds_channel_do_link(channel, client, link_mess, link->stream);
- free(link_mess);
+ g_free(link_mess);
}
link->stream = NULL;
link->link_mess = NULL;
@@ -2378,7 +2378,7 @@ static void reds_handle_read_header_done(void *opaque)
return;
}
- link->link_mess = spice_malloc(header->size);
+ link->link_mess = g_malloc(header->size);
reds_stream_async_read(link->stream,
(uint8_t *)link->link_mess,
commit 68d5f907743a7ea504521e847c1df001c0d07f8a
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 18:52:57 2017 +0100
Use GLib memory functions for SpiceChannelEventInfo
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/reds-stream.c b/server/reds-stream.c
index d4925712..817564e2 100644
--- a/server/reds-stream.c
+++ b/server/reds-stream.c
@@ -417,7 +417,7 @@ RedsStream *reds_stream_new(RedsState *reds, int socket)
stream = g_malloc0(sizeof(RedsStream) + sizeof(RedsStreamPrivate));
stream->priv = (RedsStreamPrivate *)(stream+1);
- stream->priv->info = spice_new0(SpiceChannelEventInfo, 1);
+ stream->priv->info = g_new0(SpiceChannelEventInfo, 1);
stream->priv->reds = reds;
stream->priv->core = reds_get_core_interface(reds);
reds_stream_set_socket(stream, socket);
diff --git a/server/reds.c b/server/reds.c
index 12c33570..3a0fbb51 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -325,7 +325,7 @@ void reds_handle_channel_event(RedsState *reds, int event, SpiceChannelEventInfo
reds->core.channel_event(&reds->core, event, info);
if (event == SPICE_CHANNEL_EVENT_DISCONNECTED) {
- free(info);
+ g_free(info);
}
}
commit b30f57dca4db13f574ddf188c949178f5064d096
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 18:46:04 2017 +0100
dispatcher: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/dispatcher.c b/server/dispatcher.c
index 7fb706f8..7e991403 100644
--- a/server/dispatcher.c
+++ b/server/dispatcher.c
@@ -112,7 +112,7 @@ dispatcher_finalize(GObject *object)
close(self->priv->send_fd);
close(self->priv->recv_fd);
pthread_mutex_destroy(&self->priv->lock);
- free(self->priv->payload);
+ g_free(self->priv->payload);
G_OBJECT_CLASS(dispatcher_parent_class)->finalize(object);
}
@@ -352,7 +352,7 @@ void dispatcher_register_handler(Dispatcher *dispatcher, uint32_t message_type,
msg->size = size;
msg->ack = ack;
if (msg->size > dispatcher->priv->payload_size) {
- dispatcher->priv->payload = realloc(dispatcher->priv->payload, msg->size);
+ dispatcher->priv->payload = g_realloc(dispatcher->priv->payload, msg->size);
dispatcher->priv->payload_size = msg->size;
}
}
commit 4b4647e2afb037d96bee3d3f24f4c93e968065c0
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 18:44:28 2017 +0100
event-loop: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/event-loop.c b/server/event-loop.c
index 7f2db0f6..582782e1 100644
--- a/server/event-loop.c
+++ b/server/event-loop.c
@@ -37,7 +37,7 @@ struct SpiceTimer {
static SpiceTimer* timer_add(const SpiceCoreInterfaceInternal *iface,
SpiceTimerFunc func, void *opaque)
{
- SpiceTimer *timer = spice_malloc0(sizeof(SpiceTimer));
+ SpiceTimer *timer = g_new0(SpiceTimer, 1);
timer->context = iface->main_context;
timer->func = func;
@@ -84,7 +84,7 @@ static void timer_remove(const SpiceCoreInterfaceInternal *iface,
{
timer_cancel(iface, timer);
spice_assert(timer->source == NULL);
- free(timer);
+ g_free(timer);
}
struct SpiceWatch {
@@ -155,7 +155,7 @@ static SpiceWatch *watch_add(const SpiceCoreInterfaceInternal *iface,
spice_return_val_if_fail(fd != -1, NULL);
spice_return_val_if_fail(func != NULL, NULL);
- watch = spice_malloc0(sizeof(SpiceWatch));
+ watch = g_new0(SpiceWatch, 1);
watch->context = iface->main_context;
watch->channel = g_io_channel_unix_new(fd);
watch->func = func;
@@ -173,7 +173,7 @@ static void watch_remove(const SpiceCoreInterfaceInternal *iface,
spice_assert(watch->source == NULL);
g_io_channel_unref(watch->channel);
- free(watch);
+ g_free(watch);
}
const SpiceCoreInterfaceInternal event_loop_core = {
commit 4bab960c4e9755bb821a395675eacefd9b8499c3
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 18:42:25 2017 +0100
char-device: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/char-device.c b/server/char-device.c
index 658f9f36..ef361b7a 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -150,8 +150,8 @@ static void red_char_device_write_buffer_free(RedCharDeviceWriteBuffer *buf)
if (buf == NULL)
return;
- free(buf->buf);
- free(buf);
+ g_free(buf->buf);
+ g_free(buf);
}
static void write_buffers_queue_free(GQueue *write_queue)
@@ -210,7 +210,7 @@ static void red_char_device_client_free(RedCharDevice *dev,
}
dev->priv->clients = g_list_remove(dev->priv->clients, dev_client);
- free(dev_client);
+ g_free(dev_client);
}
static void red_char_device_handle_client_overflow(RedCharDeviceClient *dev_client)
@@ -550,7 +550,7 @@ static RedCharDeviceWriteBuffer *__red_char_device_write_buffer_get(
RedCharDeviceWriteBuffer buffer;
RedCharDeviceWriteBufferPrivate priv;
} *write_buf;
- write_buf = spice_new0(struct RedCharDeviceWriteBufferFull, 1);
+ write_buf = g_new0(struct RedCharDeviceWriteBufferFull, 1);
ret = &write_buf->buffer;
ret->priv = &write_buf->priv;
}
@@ -558,7 +558,7 @@ static RedCharDeviceWriteBuffer *__red_char_device_write_buffer_get(
spice_assert(!ret->buf_used);
if (ret->buf_size < size) {
- ret->buf = spice_realloc(ret->buf, size);
+ ret->buf = g_realloc(ret->buf, size);
ret->buf_size = size;
}
ret->priv->origin = origin;
@@ -709,7 +709,7 @@ static RedCharDeviceClient *red_char_device_client_new(RedClient *client,
{
RedCharDeviceClient *dev_client;
- dev_client = spice_new0(RedCharDeviceClient, 1);
+ dev_client = g_new0(RedCharDeviceClient, 1);
dev_client->client = client;
dev_client->send_queue = g_queue_new();
dev_client->max_send_queue_size = max_send_queue_size;
commit 777af4fc5d14a5dfd80a53d6c7b686322bc19600
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 18:32:59 2017 +0100
gstreamer-encoder: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/gstreamer-encoder.c b/server/gstreamer-encoder.c
index b2ddfea9..04f0c02f 100644
--- a/server/gstreamer-encoder.c
+++ b/server/gstreamer-encoder.c
@@ -314,12 +314,12 @@ static void spice_gst_video_buffer_free(VideoBuffer *video_buffer)
#endif
gst_buffer_unref(buffer->gst_buffer);
}
- free(buffer);
+ g_free(buffer);
}
static SpiceGstVideoBuffer* create_gst_video_buffer(void)
{
- SpiceGstVideoBuffer *buffer = spice_new0(SpiceGstVideoBuffer, 1);
+ SpiceGstVideoBuffer *buffer = g_new0(SpiceGstVideoBuffer, 1);
buffer->base.free = spice_gst_video_buffer_free;
return buffer;
}
@@ -1161,7 +1161,7 @@ static void clear_zero_copy_queue(SpiceGstEncoder *encoder, gboolean unref_queue
static BitmapWrapper *bitmap_wrapper_new(SpiceGstEncoder *encoder, gpointer bitmap_opaque)
{
- BitmapWrapper *wrapper = spice_new(BitmapWrapper, 1);
+ BitmapWrapper *wrapper = g_new(BitmapWrapper, 1);
wrapper->refs = 1;
wrapper->encoder = encoder;
wrapper->opaque = bitmap_opaque;
@@ -1174,7 +1174,7 @@ static void bitmap_wrapper_unref(gpointer data)
BitmapWrapper *wrapper = data;
if (g_atomic_int_dec_and_test(&wrapper->refs)) {
g_async_queue_push(wrapper->encoder->unused_bitmap_opaques, wrapper->opaque);
- free(wrapper);
+ g_free(wrapper);
}
}
@@ -1460,7 +1460,7 @@ static void spice_gst_encoder_destroy(VideoEncoder *video_encoder)
/* Unref any lingering bitmap opaque structures from past frames */
clear_zero_copy_queue(encoder, TRUE);
- free(encoder);
+ g_free(encoder);
}
static int spice_gst_encoder_encode_frame(VideoEncoder *video_encoder,
@@ -1751,7 +1751,7 @@ VideoEncoder *gstreamer_encoder_new(SpiceVideoCodecType codec_type,
return NULL;
}
- SpiceGstEncoder *encoder = spice_new0(SpiceGstEncoder, 1);
+ SpiceGstEncoder *encoder = g_new0(SpiceGstEncoder, 1);
encoder->base.destroy = spice_gst_encoder_destroy;
encoder->base.encode_frame = spice_gst_encoder_encode_frame;
encoder->base.client_stream_report = spice_gst_encoder_client_stream_report;
@@ -1771,13 +1771,13 @@ VideoEncoder *gstreamer_encoder_new(SpiceVideoCodecType codec_type,
pthread_mutex_init(&encoder->outbuf_mutex, NULL);
pthread_cond_init(&encoder->outbuf_cond, NULL);
- /* All the other fields are initialized to zero by spice_new0(). */
+ /* All the other fields are initialized to zero by g_new0(). */
if (!create_pipeline(encoder)) {
/* Some GStreamer dependency is probably missing */
pthread_cond_destroy(&encoder->outbuf_cond);
pthread_mutex_destroy(&encoder->outbuf_mutex);
- free(encoder);
+ g_free(encoder);
encoder = NULL;
}
return (VideoEncoder*)encoder;
commit 81816e09e6805441542e69517ed1936622affc06
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 18:28:53 2017 +0100
spicevmc: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/spicevmc.c b/server/spicevmc.c
index 6b9b96fc..f56f50ed 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -437,18 +437,18 @@ static void red_port_init_item_free(struct RedPipeItem *base)
{
RedPortInitPipeItem *item = SPICE_UPCAST(RedPortInitPipeItem, base);
- free(item->name);
- free(item);
+ g_free(item->name);
+ g_free(item);
}
static void spicevmc_port_send_init(RedChannelClient *rcc)
{
RedVmcChannel *channel = RED_VMC_CHANNEL(red_channel_client_get_channel(rcc));
SpiceCharDeviceInstance *sin = channel->chardev_sin;
- RedPortInitPipeItem *item = spice_new(RedPortInitPipeItem, 1);
+ RedPortInitPipeItem *item = g_new(RedPortInitPipeItem, 1);
red_pipe_item_init_full(&item->base, RED_PIPE_ITEM_TYPE_PORT_INIT, red_port_init_item_free);
- item->name = strdup(sin->portname);
+ item->name = g_strdup(sin->portname);
item->opened = channel->port_opened;
red_channel_client_pipe_add_push(rcc, &item->base);
}
@@ -589,7 +589,7 @@ static bool spicevmc_red_channel_client_handle_message(RedChannelClient *rcc,
uint32_t size,
void *msg)
{
- /* NOTE: *msg free by free() (when cb to spicevmc_red_channel_release_msg_rcv_buf
+ /* NOTE: *msg free by g_free() (when cb to spicevmc_red_channel_release_msg_rcv_buf
* with the compressed msg type) */
RedVmcChannel *channel;
SpiceCharDeviceInterface *sif;
@@ -646,7 +646,7 @@ static uint8_t *spicevmc_red_channel_alloc_msg_rcv_buf(RedChannelClient *rcc,
}
default:
- return spice_malloc(size);
+ return g_malloc(size);
}
}
@@ -665,7 +665,7 @@ static void spicevmc_red_channel_release_msg_rcv_buf(RedChannelClient *rcc,
break;
}
default:
- free(msg);
+ g_free(msg);
}
}
commit 972a878c9987ba056bf9ce38f05b8be0cfb96188
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 18:23:25 2017 +0100
stream: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/dcc.c b/server/dcc.c
index 3bf75a70..50101080 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -635,7 +635,7 @@ void dcc_stream_agent_clip(DisplayChannelClient* dcc, StreamAgent *agent)
item->clip_type = SPICE_CLIP_TYPE_RECTS;
n_rects = pixman_region32_n_rects(&agent->clip);
- item->rects = spice_malloc_n_m(n_rects, sizeof(SpiceRect), sizeof(SpiceClipRects));
+ item->rects = g_malloc(sizeof(SpiceClipRects) + n_rects * sizeof(SpiceRect));
item->rects->num_rects = n_rects;
region_ret_rects(&agent->clip, item->rects->rects, n_rects);
diff --git a/server/stream.c b/server/stream.c
index 71755ea1..c2e82c56 100644
--- a/server/stream.c
+++ b/server/stream.c
@@ -169,7 +169,7 @@ static void red_stream_clip_item_free(RedPipeItem *base)
g_return_if_fail(item->base.refcount == 0);
stream_agent_unref(display, item->stream_agent);
- free(item->rects);
+ g_free(item->rects);
g_free(item);
}
@@ -777,7 +777,7 @@ static void red_upgrade_item_free(RedPipeItem *base)
g_return_if_fail(item->base.refcount == 0);
drawable_unref(item->drawable);
- free(item->rects);
+ g_free(item->rects);
g_free(item);
}
@@ -825,7 +825,7 @@ static void dcc_detach_stream_gracefully(DisplayChannelClient *dcc,
upgrade_item->drawable = stream->current;
upgrade_item->drawable->refs++;
n_rects = pixman_region32_n_rects(&upgrade_item->drawable->tree_item.base.rgn);
- upgrade_item->rects = spice_malloc_n_m(n_rects, sizeof(SpiceRect), sizeof(SpiceClipRects));
+ upgrade_item->rects = g_malloc(sizeof(SpiceClipRects) + n_rects * sizeof(SpiceRect));
upgrade_item->rects->num_rects = n_rects;
region_ret_rects(&upgrade_item->drawable->tree_item.base.rgn,
upgrade_item->rects->rects, n_rects);
commit 02e74c86cb2d8aa9149a6248bd908d568d8ff096
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 18:15:05 2017 +0100
smartcard: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/smartcard.c b/server/smartcard.c
index fa3a55dd..5410720a 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -144,7 +144,7 @@ static void smartcard_read_buf_prepare(RedCharDeviceSmartcard *dev, VSCMsgHeader
msg_len = ntohl(vheader->length);
if (msg_len > dev->priv->buf_size) {
dev->priv->buf_size = MAX(dev->priv->buf_size * 2, msg_len + sizeof(VSCMsgHeader));
- dev->priv->buf = spice_realloc(dev->priv->buf, dev->priv->buf_size);
+ dev->priv->buf = g_realloc(dev->priv->buf, dev->priv->buf_size);
}
}
@@ -239,7 +239,7 @@ RedMsgItem *smartcard_char_device_on_message_from_device(RedCharDeviceSmartcard
spice_printerr("error: reader_id not assigned for message of type %d", vheader->type);
}
if (dev->priv->scc) {
- sent_header = spice_memdup(vheader, sizeof(*vheader) + vheader->length);
+ sent_header = g_memdup(vheader, sizeof(*vheader) + vheader->length);
/* We patch the reader_id, since the device only knows about itself, and
* we know about the sum of readers. */
sent_header->reader_id = dev->priv->reader_id;
@@ -460,14 +460,14 @@ static void smartcard_channel_send_item(RedChannelClient *rcc, RedPipeItem *item
static void smartcard_free_vsc_msg_item(RedPipeItem *base)
{
RedMsgItem *item = SPICE_UPCAST(RedMsgItem, base);
- free(item->vheader);
- free(item);
+ g_free(item->vheader);
+ g_free(item);
}
static RedMsgItem *smartcard_get_vsc_msg_item(RedChannelClient *rcc,
VSCMsgHeader *vheader)
{
- RedMsgItem *msg_item = spice_new0(RedMsgItem, 1);
+ RedMsgItem *msg_item = g_new0(RedMsgItem, 1);
red_pipe_item_init_full(&msg_item->base, RED_PIPE_ITEM_TYPE_SMARTCARD_DATA,
smartcard_free_vsc_msg_item);
@@ -593,7 +593,7 @@ red_char_device_smartcard_finalize(GObject *object)
{
RedCharDeviceSmartcard *self = RED_CHAR_DEVICE_SMARTCARD(object);
- free(self->priv->buf);
+ g_free(self->priv->buf);
G_OBJECT_CLASS(red_char_device_smartcard_parent_class)->finalize(object);
}
@@ -621,7 +621,7 @@ red_char_device_smartcard_init(RedCharDeviceSmartcard *self)
self->priv->reader_id = VSCARD_UNDEFINED_READER_ID;
self->priv->buf_size = APDUBufSize + sizeof(VSCMsgHeader);
- self->priv->buf = spice_malloc(self->priv->buf_size);
+ self->priv->buf = g_malloc(self->priv->buf_size);
self->priv->buf_pos = self->priv->buf;
}
commit ca7d588e592e697fbef300efe242cd77151ce384
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Mon Sep 11 16:50:59 2017 +0100
reds-stream: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/reds-stream.c b/server/reds-stream.c
index e5336265..d4925712 100644
--- a/server/reds-stream.c
+++ b/server/reds-stream.c
@@ -355,8 +355,8 @@ void reds_stream_free(RedsStream *s)
s->priv->sasl.len = 0;
s->priv->sasl.encodedLength = s->priv->sasl.encodedOffset = 0;
s->priv->sasl.encoded = NULL;
- free(s->priv->sasl.mechlist);
- free(s->priv->sasl.mechname);
+ g_free(s->priv->sasl.mechlist);
+ g_free(s->priv->sasl.mechname);
s->priv->sasl.mechlist = NULL;
sasl_dispose(&s->priv->sasl.conn);
s->priv->sasl.conn = NULL;
@@ -371,7 +371,7 @@ void reds_stream_free(RedsStream *s)
spice_debug("close socket fd %d", s->socket);
close(s->socket);
- free(s);
+ g_free(s);
}
void reds_stream_push_channel_event(RedsStream *s, int event)
@@ -415,7 +415,7 @@ RedsStream *reds_stream_new(RedsState *reds, int socket)
{
RedsStream *stream;
- stream = spice_malloc0(sizeof(RedsStream) + sizeof(RedsStreamPrivate));
+ stream = g_malloc0(sizeof(RedsStream) + sizeof(RedsStreamPrivate));
stream->priv = (RedsStreamPrivate *)(stream+1);
stream->priv->info = spice_new0(SpiceChannelEventInfo, 1);
stream->priv->reds = reds;
@@ -674,11 +674,9 @@ static char *addr_to_string(const char *format,
struct sockaddr_storage *sa,
socklen_t salen)
{
- char *addr;
char host[NI_MAXHOST];
char serv[NI_MAXSERV];
int err;
- size_t addrlen;
if ((err = getnameinfo((struct sockaddr *)sa, salen,
host, sizeof(host),
@@ -689,14 +687,7 @@ static char *addr_to_string(const char *format,
return NULL;
}
- /* Enough for the existing format + the 2 vars we're
- * substituting in. */
- addrlen = strlen(format) + strlen(host) + strlen(serv);
- addr = spice_malloc(addrlen + 1);
- snprintf(addr, addrlen, format, host, serv);
- addr[addrlen] = '\0';
-
- return addr;
+ return g_strdup_printf(format, host, serv);
}
static char *reds_stream_get_local_address(RedsStream *stream)
@@ -855,7 +846,7 @@ RedsSaslError reds_sasl_handle_auth_steplen(RedsStream *stream, AsyncReadDone re
* treatment */
return REDS_SASL_ERROR_OK;
} else {
- sasl->data = spice_realloc(sasl->data, sasl->len);
+ sasl->data = g_realloc(sasl->data, sasl->len);
reds_stream_async_read(stream, (uint8_t *)sasl->data, sasl->len,
read_cb, opaque);
return REDS_SASL_ERROR_OK;
@@ -974,7 +965,7 @@ RedsSaslError reds_sasl_handle_auth_startlen(RedsStream *stream, AsyncReadDone r
return REDS_SASL_ERROR_RETRY;
}
- sasl->data = spice_realloc(sasl->data, sasl->len);
+ sasl->data = g_realloc(sasl->data, sasl->len);
reds_stream_async_read(stream, (uint8_t *)sasl->data, sasl->len,
read_cb, opaque);
@@ -1009,8 +1000,8 @@ bool reds_sasl_handle_auth_mechname(RedsStream *stream, AsyncReadDone read_cb, v
}
}
- free(sasl->mechlist);
- sasl->mechlist = spice_strdup(sasl->mechname);
+ g_free(sasl->mechlist);
+ sasl->mechlist = g_strdup(sasl->mechname);
spice_debug("Validated mechname '%s'", sasl->mechname);
@@ -1029,7 +1020,7 @@ bool reds_sasl_handle_auth_mechlen(RedsStream *stream, AsyncReadDone read_cb, vo
return false;
}
- sasl->mechname = spice_malloc(sasl->len + 1);
+ sasl->mechname = g_malloc(sasl->len + 1);
spice_debug("Wait for client mechname");
reds_stream_async_read(stream, (uint8_t *)sasl->mechname, sasl->len,
@@ -1052,7 +1043,7 @@ bool reds_sasl_start_auth(RedsStream *stream, AsyncReadDone read_cb, void *opaqu
}
if (!(remoteAddr = reds_stream_get_remote_address(stream))) {
- free(localAddr);
+ g_free(localAddr);
goto error;
}
@@ -1064,8 +1055,8 @@ bool reds_sasl_start_auth(RedsStream *stream, AsyncReadDone read_cb, void *opaqu
NULL, /* Callbacks, not needed */
SASL_SUCCESS_DATA,
&sasl->conn);
- free(localAddr);
- free(remoteAddr);
+ g_free(localAddr);
+ g_free(remoteAddr);
localAddr = remoteAddr = NULL;
if (err != SASL_OK) {
@@ -1131,7 +1122,7 @@ bool reds_sasl_start_auth(RedsStream *stream, AsyncReadDone read_cb, void *opaqu
spice_debug("Available mechanisms for client: '%s'", mechlist);
- sasl->mechlist = spice_strdup(mechlist);
+ sasl->mechlist = g_strdup(mechlist);
mechlistlen = strlen(mechlist);
if (!reds_stream_write_all(stream, &mechlistlen, sizeof(uint32_t))
commit c9cbbd6196e154fda0cff6c843f599ea9fa8dc58
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Sep 19 08:58:52 2017 +0100
mjpeg: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/mjpeg-encoder.c b/server/mjpeg-encoder.c
index 07ca69c2..cb70ab1b 100644
--- a/server/mjpeg-encoder.c
+++ b/server/mjpeg-encoder.c
@@ -191,18 +191,18 @@ static uint32_t get_min_required_playback_delay(uint64_t frame_enc_size,
static void mjpeg_video_buffer_free(VideoBuffer *video_buffer)
{
MJpegVideoBuffer *buffer = (MJpegVideoBuffer*)video_buffer;
- free(buffer->base.data);
- free(buffer);
+ g_free(buffer->base.data);
+ g_free(buffer);
}
static MJpegVideoBuffer* create_mjpeg_video_buffer(void)
{
- MJpegVideoBuffer *buffer = spice_new0(MJpegVideoBuffer, 1);
+ MJpegVideoBuffer *buffer = g_new0(MJpegVideoBuffer, 1);
buffer->base.free = mjpeg_video_buffer_free;
buffer->maxsize = MJPEG_INITIAL_BUFFER_SIZE;
- buffer->base.data = malloc(buffer->maxsize);
+ buffer->base.data = g_try_malloc(buffer->maxsize);
if (!buffer->base.data) {
- free(buffer);
+ g_free(buffer);
buffer = NULL;
}
return buffer;
@@ -211,10 +211,10 @@ static MJpegVideoBuffer* create_mjpeg_video_buffer(void)
static void mjpeg_encoder_destroy(VideoEncoder *video_encoder)
{
MJpegEncoder *encoder = (MJpegEncoder*)video_encoder;
- free(encoder->cinfo.dest);
+ g_free(encoder->cinfo.dest);
jpeg_destroy_compress(&encoder->cinfo);
- free(encoder->row);
- free(encoder);
+ g_free(encoder->row);
+ g_free(encoder);
}
static uint8_t mjpeg_encoder_get_bytes_per_pixel(MJpegEncoder *encoder)
@@ -278,7 +278,7 @@ static boolean empty_mem_output_buffer(j_compress_ptr cinfo)
/* Try to allocate new buffer with double size */
nextsize = dest->bufsize * 2;
- nextbuffer = realloc(dest->buffer, nextsize);
+ nextbuffer = g_try_realloc(dest->buffer, nextsize);
if (nextbuffer == NULL)
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
@@ -304,7 +304,7 @@ static void term_mem_destination(j_compress_ptr cinfo)
* Prepare for output to a memory buffer.
* The caller must supply its own initial buffer and size.
* When the actual data output exceeds the given size, the library
- * will adapt the buffer size as necessary using the malloc()/free()
+ * will adapt the buffer size as necessary using the g_malloc()/g_free()
* functions. The buffer is available to the application after the
* compression and the application is then responsible for freeing it.
*/
@@ -323,7 +323,7 @@ spice_jpeg_mem_dest(j_compress_ptr cinfo,
* can be written to the same buffer without re-executing jpeg_mem_dest.
*/
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
- cinfo->dest = spice_malloc(sizeof(mem_destination_mgr));
+ cinfo->dest = g_malloc(sizeof(mem_destination_mgr));
}
dest = (mem_destination_mgr *) cinfo->dest;
@@ -700,7 +700,7 @@ static void mjpeg_encoder_adjust_fps(MJpegEncoder *encoder, uint64_t now)
}
/*
- * dest must be either NULL or allocated by malloc, since it might be freed
+ * dest must be either NULL or allocated by g_malloc, since it might be freed
* during the encoding, if its size is too small.
*
* return:
@@ -790,7 +790,7 @@ static int mjpeg_encoder_start_frame(MJpegEncoder *encoder,
return VIDEO_ENCODER_FRAME_UNSUPPORTED;
}
if (encoder->row_size < stride) {
- encoder->row = spice_realloc(encoder->row, stride);
+ encoder->row = g_realloc(encoder->row, stride);
encoder->row_size = stride;
}
}
@@ -1357,7 +1357,7 @@ VideoEncoder *mjpeg_encoder_new(SpiceVideoCodecType codec_type,
spice_return_val_if_fail(codec_type == SPICE_VIDEO_CODEC_TYPE_MJPEG, NULL);
- encoder = spice_new0(MJpegEncoder, 1);
+ encoder = g_new0(MJpegEncoder, 1);
encoder->base.destroy = mjpeg_encoder_destroy;
encoder->base.encode_frame = mjpeg_encoder_encode_frame;
encoder->base.client_stream_report = mjpeg_encoder_client_stream_report;
commit cd25ff8b3b42d789194724035f56410c8476d147
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Mon Sep 11 16:15:53 2017 +0100
lz4-encoder: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/lz4-encoder.c b/server/lz4-encoder.c
index fe736d27..39aac012 100644
--- a/server/lz4-encoder.c
+++ b/server/lz4-encoder.c
@@ -74,7 +74,7 @@ int lz4_encode(Lz4EncoderContext *lz4, int height, int stride, uint8_t *io_ptr,
in_size = stride * num_lines;
lines += in_size;
int bound_size = LZ4_compressBound(in_size);
- compressed_lines = (uint8_t *) malloc(bound_size + 4);
+ compressed_lines = g_new(uint8_t, bound_size + 4);
#ifdef HAVE_LZ4_COMPRESS_FAST_CONTINUE
enc_size = LZ4_compress_fast_continue(stream, (const char *) in_buf,
(char *) compressed_lines + 4, in_size,
@@ -85,7 +85,7 @@ int lz4_encode(Lz4EncoderContext *lz4, int height, int stride, uint8_t *io_ptr,
#endif
if (enc_size <= 0) {
spice_error("compress failed!");
- free(compressed_lines);
+ g_free(compressed_lines);
LZ4_freeStream(stream);
return 0;
}
@@ -100,7 +100,7 @@ int lz4_encode(Lz4EncoderContext *lz4, int height, int stride, uint8_t *io_ptr,
num_io_bytes = enc->usr->more_space(enc->usr, &io_ptr);
if (num_io_bytes <= 0) {
spice_error("more space failed");
- free(compressed_lines);
+ g_free(compressed_lines);
LZ4_freeStream(stream);
return 0;
}
@@ -110,7 +110,7 @@ int lz4_encode(Lz4EncoderContext *lz4, int height, int stride, uint8_t *io_ptr,
out_buf += enc_size;
num_io_bytes -= enc_size;
- free(compressed_lines);
+ g_free(compressed_lines);
total_lines += num_lines;
} while (total_lines < height);
More information about the Spice-commits
mailing list