Il 15/02/2013 17:17, Peter Maydell ha scritto: > But these memory regions belong to this device -- we own them and > they won't go away until the device is destroyed [which is never, > as it happens, for this device.] More generally, if it's valid > for us to hold a MemoryRegion* and call memory_region_get_ram_ptr() > in the read/write function, it's just as valid to keep the ram pointer: > the two have exactly matching lifetimes, unless I'm missing something.
No, you're not: "In practice it should be handled just fine by reference counting, but I still find it harder to wrap my head around it". > (as an aside, memory_region_destroy() doesn't free the memory that > memory_region_init_ram() allocates.) Paolo