qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [patch] replace all strdup() with g_strdup()


From: Peter Maydell
Subject: Re: [Qemu-devel] [patch] replace all strdup() with g_strdup()
Date: Fri, 16 Dec 2011 09:26:33 +0000

On 16 December 2011 08:07, Jun Koi <address@hidden> wrote:
> This patch replaces all the strdup() with g_strdup()

I don't think you can do this as a pure search-and-replace.
For example this change:
> --- a/envlist.c
> +++ b/envlist.c
> @@ -109,7 +109,7 @@ envlist_parse(envlist_t *envlist, const char *env,
>        * We need to make temporary copy of the env string
>        * as strtok_r(3) modifies it while it tokenizes.
>        */
> -     if ((tmpenv = strdup(env)) == NULL)
> +     if ((tmpenv = g_strdup(env)) == NULL)
>               return (errno);
>
>       envvar = strtok_r(tmpenv, ",", &envsave);

means we're allocating memory with g_strdup but freeing it with
plain free rather than g_free.

You have to take each usage of memory, look for all the places which
allocate/free/strdup it, and change them all at once.

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]