[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH-for-5.0] gdbstub: Do not use memset() on GByteArray
From: |
Alex Bennée |
Subject: |
Re: [PATCH-for-5.0] gdbstub: Do not use memset() on GByteArray |
Date: |
Tue, 14 Apr 2020 15:22:19 +0100 |
User-agent: |
mu4e 1.3.10; emacs 28.0.50 |
Peter Maydell <address@hidden> writes:
> On Tue, 14 Apr 2020 at 12:05, Philippe Mathieu-Daudé <address@hidden> wrote:
>> > The other implementation option here would be
>> >
>> > guint oldlen = array->len;
>> > g_byte_array_set_size(array, oldlen + len);
>> > memset(array->data + oldlen, 0, len);
>>
>> I thought about it but I'd rather not access GByteArray internals.
>
> AIUI ->len and ->data are not internals -- they're
> in the documentation as "public fields" and the code
> example for GByteArray directly accesses ->data.
They are - and I do it in a few places in the gdbstub when it's easier
than going long form. FWIW I prefer Peter's formulation.
> (Contrast GBytes, where there are no defined public
> fields and instead there are functions g_bytes_get_data
> and g_bytes_get_size.)
>
> thanks
> -- PMM
--
Alex Bennée