Commit d31a0ebfc8 for qemu.org
commit d31a0ebfc80b8a36dcdd6eba3d911231c27e0a22
Author: Marc-André Lureau <marcandre.lureau@redhat.com>
Date: Mon May 4 10:32:07 2026 +0400
system/ioport: minor code simplification
Drop needless memset() and replace g_malloc0() with g_new().
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
diff --git a/system/ioport.c b/system/ioport.c
index 1a0e01fd06..0a1b80f299 100644
--- a/system/ioport.c
+++ b/system/ioport.c
@@ -230,9 +230,8 @@ static void portio_list_add_1(PortioList *piolist,
mrpio = MEMORY_REGION_PORTIO_LIST(
object_new(TYPE_MEMORY_REGION_PORTIO_LIST));
mrpio->portio_opaque = piolist->opaque;
- mrpio->ports = g_malloc0(sizeof(MemoryRegionPortio) * (count + 1));
+ mrpio->ports = g_new0(MemoryRegionPortio, count + 1);
memcpy(mrpio->ports, pio_init, sizeof(MemoryRegionPortio) * count);
- memset(mrpio->ports + count, 0, sizeof(MemoryRegionPortio));
/* Adjust the offsets to all be zero-based for the region. */
for (i = 0; i < count; ++i) {