On 20/04/2018 19:06, Peter Maydell wrote: > On 20 April 2018 at 17:58, Paolo Bonzini <pbonz...@redhat.com> wrote: >> On 20/04/2018 16:52, Peter Maydell wrote: >>> Instead of having a fixed sized global serial_hds[] array, >>> use a local dynamically reallocated one, so we don't have >>> a compile time limit on how many serial ports a system has. >>> >>> Signed-off-by: Peter Maydell <peter.mayd...@linaro.org> >> >> Just one question, would it make sense to use a GPtrArray instead? > > Hmm. Looking at the GPtrArray API there's no API for > "tell me the length of this pointer array", so we'd still > have to do the manual bookkeeping for that. And we don't > need most of the functionality it provides. So it doesn't > really seem like it gains us much over g_renew() to me.
GPtrArray is a public struct, so you can use array->pdata and array->len. There is a disadvantage, which is that you lose type-safety on dereference. Paolo