[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 4/5] tests/i44fx-test: No need for zeroing memor
From: |
Laszlo Ersek |
Subject: |
Re: [Qemu-devel] [PATCH 4/5] tests/i44fx-test: No need for zeroing memory before memset |
Date: |
Thu, 8 Oct 2015 22:24:31 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 10/08/15 21:35, Thomas Huth wrote:
> Change a g_malloc0 into g_malloc since the following
> memset fills the whole buffer anyway.
>
> Cc: Laszlo Ersek <address@hidden>
> Signed-off-by: Thomas Huth <address@hidden>
> ---
> tests/i440fx-test.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/i440fx-test.c b/tests/i440fx-test.c
> index d0bc8de..7fa1709 100644
> --- a/tests/i440fx-test.c
> +++ b/tests/i440fx-test.c
> @@ -191,7 +191,7 @@ static void write_area(uint32_t start, uint32_t end,
> uint8_t value)
> uint32_t size = end - start + 1;
> uint8_t *data;
>
> - data = g_malloc0(size);
> + data = g_malloc(size);
> memset(data, value, size);
> memwrite(start, data, size);
>
>
Technically you are right of course, but I remember some historical mess
around this, in this file.
Plus I vaguely recall g_new[0]() being the most recent preference.
https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html#g-new
See e.g. commit 97f3ad3551. Markus?
Thanks
Laszlo