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

Re: [libvirt] [PATCH REPOST 16/38] virlog: Introduce virLogOutputListFree



On 05/04/2016 10:30 AM, Erik Skultety wrote:
> This is just a convenience method for discarding a list of outputs instead of
> using a 'for' loop everywhere. It is safe to pass -1 as the number of elements
> in the list as well as passing NULL as list reference.
> ---
>  src/libvirt_private.syms |  1 +
>  src/util/virlog.c        | 20 ++++++++++++++++++++
>  src/util/virlog.h        |  1 +
>  3 files changed, 22 insertions(+)
> 
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index b40a405..608d959 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -1795,6 +1795,7 @@ virLogGetOutputs;
>  virLogLock;
>  virLogMessage;
>  virLogOutputFree;
> +virLogOutputListFree;
>  virLogOutputNew;
>  virLogParseDefaultPriority;
>  virLogParseFilters;
> diff --git a/src/util/virlog.c b/src/util/virlog.c
> index e36ff73..5da1af7 100644
> --- a/src/util/virlog.c
> +++ b/src/util/virlog.c
> @@ -1600,3 +1600,23 @@ virLogDefineFilters(virLogFilterPtr *filters, size_t nfilters)
>  
>      return virLogNbFilters;
>  }
> +
> +/**
> + * virLogOutputsFreeList:
> + * @list: list of outputs to be freed
> + * @count: number of elements in the list
> + *
> + * Frees a list of outputs.
> + */
> +void
> +virLogOutputListFree(virLogOutputPtr *list, int count)
> +{
> +    size_t i;
> +
> +    if (!list || count < 0)
> +        return;
> +
> +    for (i = 0; i < count; i++)
> +        virLogOutputFree(list[i]);
> +    VIR_FREE(list);
> +}
> diff --git a/src/util/virlog.h b/src/util/virlog.h
> index 7573984..4f0eea7 100644
> --- a/src/util/virlog.h
> +++ b/src/util/virlog.h
> @@ -196,6 +196,7 @@ extern int virLogOutputNew(virLogOutputFunc f,
>                             const char *name,
>                             unsigned int flags);
>  extern void virLogOutputFree(virLogOutputPtr output);
> +extern void virLogOutputListFree(virLogOutputPtr *list, int count);
>  
>  /*
>   * Internal logging API
> 

Why not convert virLogResetOutputs at the same time, like was done in the
previous patch? ACK with that (unless I missed some subtlety)

- Cole


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