[Spice-devel] [PATCH spice-server 1/6] spicevmc: Use spice_new instead of spice_malloc
Uri Lublin
uril at redhat.com
Thu Jan 26 13:39:39 UTC 2017
On 01/26/2017 12:56 PM, Frediano Ziglio wrote:
> spice_new is a bit more safe as return a properly typed pointer.
Hi Frediano,
I do not think it's much safer, as spice_new is just
a #define macro that (with second param 1)
calls spice_malloc and casts from void* ; but
it does not hurt either, so fine by me.
Uri.
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> server/spicevmc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/server/spicevmc.c b/server/spicevmc.c
> index bbe72b5..0dc2b19 100644
> --- a/server/spicevmc.c
> +++ b/server/spicevmc.c
> @@ -380,7 +380,7 @@ 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_malloc(sizeof(RedPortInitPipeItem));
> + RedPortInitPipeItem *item = spice_new(RedPortInitPipeItem, 1);
>
> red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_PORT_INIT);
> item->name = strdup(sin->portname);
> @@ -390,7 +390,7 @@ static void spicevmc_port_send_init(RedChannelClient *rcc)
>
> static void spicevmc_port_send_event(RedChannelClient *rcc, uint8_t event)
> {
> - RedPortEventPipeItem *item = spice_malloc(sizeof(RedPortEventPipeItem));
> + RedPortEventPipeItem *item = spice_new(RedPortEventPipeItem, 1);
>
> red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_PORT_EVENT);
> item->event = event;
>
More information about the Spice-devel
mailing list