[vlc-devel] [PATCH] src: Win32: add message categories to debug logs

Rafaël Carré funman at videolan.org
Sun Feb 3 15:46:28 CET 2013


Le 03/02/2013 15:12, Edward Wang a écrit :
> ---
>  src/misc/messages.c |   11 ++++++++---
>  1 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/src/misc/messages.c b/src/misc/messages.c
> index 1d8fd0b..d754b7c 100644
> --- a/src/misc/messages.c
> +++ b/src/misc/messages.c
> @@ -325,9 +325,14 @@ static void Win32DebugOutputMsg (void* d, int type, const msg_item_t *p_item,
>              msg[msg_len] = '\n';
>              msg[msg_len + 1] = '\0';
>          }
> -        wchar_t *wmsg = ToWide(msg);
> -        OutputDebugStringW(wmsg);
> -        free(wmsg);
> +        char* psz_msg = NULL;
> +        if(asprintf(&psz_msg, "%s %s%s: %s", p_item->psz_module,
> +                    p_item->psz_object_type, msg_type[type], msg) > 0) {
> +            wchar_t* wmsg = ToWide(psz_msg);
> +            OutputDebugStringW(wmsg);
> +            free(wmsg);
> +            free(psz_msg);
> +        }

Nitpick: wmsg is leaked if asprintf fails

>      }
>      free(msg);
>  }
> 




More information about the vlc-devel mailing list