Re: [PATCH spice-server v2 06/23] spicevmc: Use GLib memory functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2017-09-20 at 08:50 +0100, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  server/spicevmc.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/server/spicevmc.c b/server/spicevmc.c
> index 6b9b96fc8..7577165f5 100644
> --- a/server/spicevmc.c
> +++ b/server/spicevmc.c
> @@ -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);

There seems to be something missing in this patch. The msg_item is
allocated in spicevmc_chardev_read_msg_from_dev() with spice_new0, but
it's freed here with g_free().


>          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
> @@ -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);
>      }
>  }
>  
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]