[Spice-devel] [PATCH 3/8] Use spice_realloc instead of manually code it

Jonathon Jongsma jjongsma at redhat.com
Wed Sep 21 08:40:17 UTC 2016


Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

On Mon, 2016-09-19 at 09:29 +0100, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/dcc.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/server/dcc.c b/server/dcc.c
> index a56b658..c9d0231 100644
> --- a/server/dcc.c
> +++ b/server/dcc.c
> @@ -811,14 +811,9 @@ static void
> dcc_push_release(DisplayChannelClient *dcc, uint8_t type, uint64_t i
>      }
>  
>      if (free_list->res->count == free_list->res_size) {
> -        SpiceResourceList *new_list;
> -        new_list = spice_malloc(sizeof(*new_list) +
> -                                free_list->res_size *
> sizeof(SpiceResourceID) * 2);
> -        new_list->count = free_list->res->count;
> -        memcpy(new_list->resources, free_list->res->resources,
> -               new_list->count * sizeof(SpiceResourceID));
> -        free(free_list->res);
> -        free_list->res = new_list;
> +        free_list->res = spice_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;


More information about the Spice-devel mailing list