On 02/09/20 10:28, Philippe Mathieu-Daudé wrote:
>>  
>> -void qemu_add_data_dir(const char *path)
>> +void qemu_add_data_dir(char *path)
> But we have 'const char *data_dir[16];', why remove the const?

In order to free duplicates: before this patch the directory can be
statically- or stack-allocated, now it's always heap-allocated.

Paolo

>  {
>      int i;
>  
> @@ -2017,10 +2017,11 @@ void qemu_add_data_dir(const char *path)
>      }
>      for (i = 0; i < data_dir_idx; i++) {
>          if (strcmp(data_dir[i], path) == 0) {
> -            return; /* duplicate */
> +            g_free(path); /* duplicate */
> +            return;
>          }
>      }
> -    data_dir[data_dir_idx++] = g_strdup(path);
> +    data_dir[data_dir_idx++] = path;
>  }

Paolo


Reply via email to