On Thu, 30 Oct 2025, Paolo Bonzini wrote:
On 10/29/25 20:20, Peter Xu wrote:
On Wed, Oct 29, 2025 at 11:30:10AM +0100, BALATON Zoltan wrote:
memory_region_new_* will work, but I don't think removing unnecessary
but harmless fields from a device state structure does not sufficiently
motivates adding them.

I haven't given up on this yet, that's why I alternatively proposed

object_alloc (same as object_new without object_initialize)
memory_region_init

which is just a small change but should also work without adding
memory_region_new convenience functions. Then only object_alloc needs to be
added.

IMHO if this will ever happen, memory_region_new*() is better, unless
object_alloc() can be used anywhere besides MemoryRegion..

Objective-C (*step/macOS and derivatives) have two methods for creating objects: alloc then init. It also has "new" to combine both but exposing alloc is sometimes useful especially when having different init methods. I was thinking doing it that way which should be familiar to at least to some people. I'll explore that in a proposed series.

It seems to me, MemoryRegion is the only one I'm aware of that may need
such tweak, rather than using object_new() directly.

Yes, pretty much.  Anyhow, leaking on purpose with g_new is not a good idea.

It does not leak in this case. This object is a host bridge created once and start and never removed and is not user creatable being a sysbus device. It's still theoretically incorrect but this patch did not introduce any new problems just made it clearer by moving it from board to device.

Regards,
BALATON Zoltan

Reply via email to