[Spice-devel] [PATCH spice-common 1/5] canvas: Simplify code using spice_memdup

Uri Lublin uril at redhat.com
Wed Jan 17 17:40:43 UTC 2018


Hi Frediano,

Some of those changes are a matter of style (e.g. remove variable).

Ack Series.

Thanks,
     Uri.

On 01/17/2018 05:55 PM, Frediano Ziglio wrote:
> Instead of using spice_malloc+memcpy use spice_memdup which is
> doing the same.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>   common/canvas_base.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/common/canvas_base.c b/common/canvas_base.c
> index 39439ed..f4f301c 100644
> --- a/common/canvas_base.c
> +++ b/common/canvas_base.c
> @@ -737,16 +737,13 @@ static inline SpicePalette *canvas_get_localized_palette(CanvasBase *canvas, Spi
>       SpicePalette *palette = canvas_get_palette(canvas, base_palette, palette_id, flags);
>       SpicePalette *copy;
>       uint32_t *now, *end;
> -    size_t size;
>   
>       if (canvas->format == SPICE_SURFACE_FMT_32_xRGB ||
>           canvas->format == SPICE_SURFACE_FMT_32_ARGB) {
>           return palette;
>       }
>   
> -    size = sizeof(SpicePalette) + palette->num_ents * 4;
> -    copy = (SpicePalette *)spice_malloc(size);
> -    memcpy(copy, palette, size);
> +    copy = spice_memdup(palette, sizeof(SpicePalette) + palette->num_ents * 4);
>   
>       switch (canvas->format) {
>       case SPICE_SURFACE_FMT_32_xRGB:
> 



More information about the Spice-devel mailing list