mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-08-08 18:37:34 +00:00
Automatically release some pipe item resources
Now that items are managed by constructors/destructors avoid some manual releases. Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Acked-by: Julien Ropé <jrope@gmail.com>
This commit is contained in:
parent
fa404f73d8
commit
93405ae3c6
@ -2158,7 +2158,7 @@ static void marshall_stream_clip(DisplayChannelClient *dcc,
|
||||
|
||||
stream_clip.id = display_channel_get_video_stream_id(DCC_TO_DC(dcc), agent->stream);
|
||||
stream_clip.clip.type = item->clip_type;
|
||||
stream_clip.clip.rects = item->rects;
|
||||
stream_clip.clip.rects = item->rects.get();
|
||||
|
||||
spice_marshall_msg_display_stream_clip(base_marshaller, &stream_clip);
|
||||
}
|
||||
@ -2194,7 +2194,7 @@ static void marshall_upgrade(DisplayChannelClient *dcc, SpiceMarshaller *m,
|
||||
copy.base.surface_id = 0;
|
||||
copy.base.box = red_drawable->bbox;
|
||||
copy.base.clip.type = SPICE_CLIP_TYPE_RECTS;
|
||||
copy.base.clip.rects = item->rects;
|
||||
copy.base.clip.rects = item->rects.get();
|
||||
copy.data = red_drawable->u.copy;
|
||||
|
||||
spice_marshall_msg_display_draw_copy(m, ©,
|
||||
|
||||
@ -87,8 +87,7 @@ struct RedUuidPipeItem: public RedPipeItemNum<RED_PIPE_ITEM_TYPE_MAIN_UUID> {
|
||||
};
|
||||
|
||||
struct RedNotifyPipeItem: public RedPipeItemNum<RED_PIPE_ITEM_TYPE_MAIN_NOTIFY> {
|
||||
~RedNotifyPipeItem();
|
||||
char *msg;
|
||||
red::glib_unique_ptr<char> msg;
|
||||
};
|
||||
|
||||
struct RedMouseModePipeItem: public RedPipeItemNum<RED_PIPE_ITEM_TYPE_MAIN_MOUSE_MODE> {
|
||||
@ -143,16 +142,11 @@ void MainChannelClient::on_disconnect()
|
||||
|
||||
static void main_channel_client_push_ping(MainChannelClient *mcc, int size);
|
||||
|
||||
RedNotifyPipeItem::~RedNotifyPipeItem()
|
||||
{
|
||||
g_free(msg);
|
||||
}
|
||||
|
||||
static RedPipeItem *main_notify_item_new(const char *msg, int num)
|
||||
{
|
||||
RedNotifyPipeItem *item = new RedNotifyPipeItem();
|
||||
|
||||
item->msg = g_strdup(msg);
|
||||
item->msg.reset(g_strdup(msg));
|
||||
return item;
|
||||
}
|
||||
|
||||
@ -675,9 +669,9 @@ static void main_channel_marshall_notify(RedChannelClient *rcc,
|
||||
notify.severity = SPICE_NOTIFY_SEVERITY_WARN;
|
||||
notify.visibilty = SPICE_NOTIFY_VISIBILITY_HIGH;
|
||||
notify.what = SPICE_WARN_GENERAL;
|
||||
notify.message_len = strlen(item->msg);
|
||||
notify.message_len = strlen(item->msg.get());
|
||||
spice_marshall_msg_notify(m, ¬ify);
|
||||
spice_marshaller_add(m, (uint8_t *)item->msg, notify.message_len + 1);
|
||||
spice_marshaller_add(m, (uint8_t *)item->msg.get(), notify.message_len + 1);
|
||||
}
|
||||
|
||||
static void main_channel_fill_migrate_dst_info(MainChannel *main_channel,
|
||||
|
||||
@ -68,8 +68,7 @@ struct RedCharDeviceSmartcardPrivate {
|
||||
};
|
||||
|
||||
struct RedMsgItem: public RedPipeItemNum<RED_PIPE_ITEM_TYPE_SMARTCARD_DATA> {
|
||||
~RedMsgItem();
|
||||
VSCMsgHeader* vheader;
|
||||
red::glib_unique_ptr<VSCMsgHeader> vheader;
|
||||
};
|
||||
|
||||
static RedMsgItem *smartcard_new_vsc_msg_item(unsigned int reader_id, const VSCMsgHeader *vheader);
|
||||
@ -339,7 +338,7 @@ static void smartcard_channel_send_msg(RedChannelClient *rcc,
|
||||
{
|
||||
RedMsgItem* msg_item = static_cast<RedMsgItem*>(item);
|
||||
|
||||
smartcard_channel_client_send_data(rcc, m, item, msg_item->vheader);
|
||||
smartcard_channel_client_send_data(rcc, m, item, msg_item->vheader.get());
|
||||
}
|
||||
|
||||
static void smartcard_channel_send_migrate_data(SmartCardChannelClient *scc,
|
||||
@ -389,16 +388,11 @@ void SmartCardChannelClient::send_item(RedPipeItem *item)
|
||||
begin_send_message();
|
||||
}
|
||||
|
||||
RedMsgItem::~RedMsgItem()
|
||||
{
|
||||
g_free(vheader);
|
||||
}
|
||||
|
||||
static RedMsgItem *smartcard_new_vsc_msg_item(unsigned int reader_id, const VSCMsgHeader *vheader)
|
||||
{
|
||||
RedMsgItem *msg_item = new RedMsgItem();
|
||||
|
||||
msg_item->vheader = (VSCMsgHeader*) g_memdup(vheader, sizeof(*vheader) + vheader->length);
|
||||
msg_item->vheader.reset((VSCMsgHeader*) 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. */
|
||||
msg_item->vheader->reader_id = reader_id;
|
||||
|
||||
@ -189,9 +189,7 @@ static red::shared_ptr<RedVmcChannel> red_vmc_channel_new(RedsState *reds, uint8
|
||||
}
|
||||
|
||||
struct RedPortInitPipeItem: public RedPipeItemNum<RED_PIPE_ITEM_TYPE_PORT_INIT> {
|
||||
~RedPortInitPipeItem();
|
||||
|
||||
char* name;
|
||||
red::glib_unique_ptr<char> name;
|
||||
uint8_t opened;
|
||||
};
|
||||
|
||||
@ -285,18 +283,13 @@ RedPipeItem* RedCharDeviceSpiceVmc::read_one_msg_from_device()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RedPortInitPipeItem::~RedPortInitPipeItem()
|
||||
{
|
||||
g_free(name);
|
||||
}
|
||||
|
||||
static void spicevmc_port_send_init(VmcChannelClient *rcc)
|
||||
{
|
||||
RedVmcChannel *channel = rcc->get_channel();
|
||||
SpiceCharDeviceInstance *sin = channel->chardev_sin;
|
||||
RedPortInitPipeItem *item = new RedPortInitPipeItem();
|
||||
|
||||
item->name = g_strdup(sin->portname);
|
||||
item->name.reset(g_strdup(sin->portname));
|
||||
item->opened = channel->port_opened;
|
||||
rcc->pipe_add_push(item);
|
||||
}
|
||||
@ -556,8 +549,8 @@ static void spicevmc_red_channel_send_port_init(RedChannelClient *rcc,
|
||||
SpiceMsgPortInit init;
|
||||
|
||||
rcc->init_send_data(SPICE_MSG_PORT_INIT);
|
||||
init.name = (uint8_t *)i->name;
|
||||
init.name_size = strlen(i->name) + 1;
|
||||
init.name = (uint8_t *)i->name.get();
|
||||
init.name_size = strlen(i->name.get()) + 1;
|
||||
init.opened = i->opened;
|
||||
spice_marshall_msg_port_init(m, &init);
|
||||
}
|
||||
|
||||
@ -164,7 +164,6 @@ VideoStreamClipItem::~VideoStreamClipItem()
|
||||
DisplayChannel *display = DCC_TO_DC(stream_agent->dcc);
|
||||
|
||||
video_stream_agent_unref(display, stream_agent);
|
||||
g_free(rects);
|
||||
}
|
||||
|
||||
VideoStreamClipItem *video_stream_clip_item_new(VideoStreamAgent *agent)
|
||||
@ -177,7 +176,8 @@ VideoStreamClipItem *video_stream_clip_item_new(VideoStreamAgent *agent)
|
||||
item->clip_type = SPICE_CLIP_TYPE_RECTS;
|
||||
|
||||
int n_rects = pixman_region32_n_rects(&agent->clip);
|
||||
item->rects = (SpiceClipRects*) g_malloc(sizeof(SpiceClipRects) + n_rects * sizeof(SpiceRect));
|
||||
item->rects.reset((SpiceClipRects*) g_malloc(sizeof(SpiceClipRects) +
|
||||
n_rects * sizeof(SpiceRect)));
|
||||
item->rects->num_rects = n_rects;
|
||||
region_ret_rects(&agent->clip, item->rects->rects, n_rects);
|
||||
|
||||
@ -803,7 +803,6 @@ void video_stream_agent_stop(VideoStreamAgent *agent)
|
||||
RedUpgradeItem::~RedUpgradeItem()
|
||||
{
|
||||
drawable_unref(drawable);
|
||||
g_free(rects);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -846,7 +845,8 @@ 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 = (SpiceClipRects*) g_malloc(sizeof(SpiceClipRects) + n_rects * sizeof(SpiceRect));
|
||||
upgrade_item->rects.reset((SpiceClipRects*) 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);
|
||||
|
||||
@ -53,7 +53,7 @@ struct RedUpgradeItem: public RedPipeItem {
|
||||
using RedPipeItem::RedPipeItem;
|
||||
~RedUpgradeItem();
|
||||
Drawable *drawable;
|
||||
SpiceClipRects *rects;
|
||||
red::glib_unique_ptr<SpiceClipRects> rects;
|
||||
};
|
||||
|
||||
struct RedStreamActivateReportItem: public RedPipeItem {
|
||||
@ -101,7 +101,7 @@ struct VideoStreamClipItem: public RedPipeItem {
|
||||
~VideoStreamClipItem();
|
||||
VideoStreamAgent *stream_agent;
|
||||
int clip_type;
|
||||
SpiceClipRects *rects;
|
||||
red::glib_unique_ptr<SpiceClipRects> rects;
|
||||
};
|
||||
|
||||
VideoStreamClipItem *video_stream_clip_item_new(VideoStreamAgent *agent);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user