Now that we don't save the property name in Property.name anymore, we don't need the to keep the property name string alive after the property was registered.
We can remove the ArrayElementProperty.propname field, and free the string immediately after registering the property. Signed-off-by: Eduardo Habkost <ehabk...@redhat.com> --- This is a new patch added in v2 of the series --- Cc: Paolo Bonzini <pbonz...@redhat.com> Cc: "Daniel P. Berrangé" <berra...@redhat.com> Cc: Eduardo Habkost <ehabk...@redhat.com> Cc: qemu-devel@nongnu.org --- hw/core/qdev-properties.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 4cbdd34a04..a0192c3723 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -533,7 +533,6 @@ const PropertyInfo qdev_prop_size32 = { */ typedef struct { struct Property prop; - char *propname; ObjectPropertyRelease *release; } ArrayElementProperty; @@ -547,7 +546,6 @@ static void array_element_release(Object *obj, const char *name, void *opaque) if (p->release) { p->release(obj, name, opaque); } - g_free(p->propname); g_free(p); } @@ -590,10 +588,9 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name, */ *arrayptr = eltptr = g_malloc0(*alenptr * prop->arrayfieldsize); for (i = 0; i < *alenptr; i++, eltptr += prop->arrayfieldsize) { - char *propname = g_strdup_printf("%s[%d]", arrayname, i); + g_autofree char *propname = g_strdup_printf("%s[%d]", arrayname, i); ArrayElementProperty *arrayprop = g_new0(ArrayElementProperty, 1); arrayprop->release = prop->arrayinfo->release; - arrayprop->propname = propname; arrayprop->prop.info = prop->arrayinfo; /* This ugly piece of pointer arithmetic sets up the offset so * that when the underlying get/set hooks call qdev_get_prop_ptr -- 2.28.0