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

Re: [libvirt] [PATCH REPOST 15/38] virlog: Introduce virLogOutputFree



On 05/04/2016 10:30 AM, Erik Skultety wrote:
> Add a complementary method to virLogOutputNew.
> ---
>  src/libvirt_private.syms |  1 +
>  src/util/virlog.c        | 21 ++++++++++++++++-----
>  src/util/virlog.h        |  1 +
>  3 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 56dfcf4..b40a405 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -1794,6 +1794,7 @@ virLogGetNbOutputs;
>  virLogGetOutputs;
>  virLogLock;
>  virLogMessage;
> +virLogOutputFree;
>  virLogOutputNew;
>  virLogParseDefaultPriority;
>  virLogParseFilters;
> diff --git a/src/util/virlog.c b/src/util/virlog.c
> index e101484..e36ff73 100644
> --- a/src/util/virlog.c
> +++ b/src/util/virlog.c
> @@ -323,16 +323,27 @@ virLogResetOutputs(void)
>  {
>      size_t i;
>  
> -    for (i = 0; i < virLogNbOutputs; i++) {
> -        if (virLogOutputs[i]->c != NULL)
> -            virLogOutputs[i]->c(virLogOutputs[i]->data);
> -        VIR_FREE(virLogOutputs[i]->name);
> -    }
> +    for (i = 0; i < virLogNbOutputs; i++)
> +        virLogOutputFree(virLogOutputs[i]);
> +
>      VIR_FREE(virLogOutputs);
>      virLogNbOutputs = 0;
>  }
>  
>  
> +void
> +virLogOutputFree(virLogOutputPtr output)
> +{
> +    if (!output)
> +        return;
> +
> +    if (output->c)
> +        output->c(output->data);
> +    VIR_FREE(output->name);
> +    VIR_FREE(output);
> +
> +}
> +
>  /**
>   * virLogOutputNew:
>   * @f: the function to call to output a message
> diff --git a/src/util/virlog.h b/src/util/virlog.h
> index 93456db..7573984 100644
> --- a/src/util/virlog.h
> +++ b/src/util/virlog.h
> @@ -195,6 +195,7 @@ extern int virLogOutputNew(virLogOutputFunc f,
>                             virLogDestination dest,
>                             const char *name,
>                             unsigned int flags);
> +extern void virLogOutputFree(virLogOutputPtr output);
>  
>  /*
>   * Internal logging API
> 

ACK

(sidenote: I know you were following existing convention but the usage of
extern forward declarations in the header is confusing to me... my brain is
wired to see header declaration == public function)

- Cole


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