On Thu, 12 Aug 2021 at 13:13, Alexandre IOOSS <erdn...@crans.org> wrote:
>
> On 8/12/21 11:33 AM, Peter Maydell wrote:
> > In the realize methods of the stm32f100 and stm32f205 SoC objects, we
> > call g_new() to create new MemoryRegion objjects for the sram, flash,
> > and flash_alias.  This is unnecessary (and leaves open the
> > possibility of leaking the allocations if we exit from realize with
> > an error).  Make these MemoryRegions member fields of the device
> > state struct instead, as stm32f405 already does.
>
> There is a typo in "objjects".
>
> This is something I had issue understanding as I was seeing both
> patterns in the codebase, thank you for making this clear.

Basically if there's a struct that the MemoryRegion can live
in  then that's the best place for it. For some board-level code
where we haven't needed to subclass MachineState there is no
convenient struct, so we just g_new(). In a few places like this
one the board-code pattern has been copied into an SoC object.

-- PMM

Reply via email to