[PATCH 1/6] Remove some manual memory management from compile interface

Simon Marchi simark@simark.ca
Sat Sep 19 23:52:33 GMT 2020


On 2020-09-19 7:45 p.m., Tom Tromey wrote:
> Simon> You could now remove this `if (num_baseclasses > 0)`, there's no
> Simon> reason for it anymore I think.
>
> I looked at this more deeply, and based on the compiler library, I think
> the rule is that a 0-length array should be passed as nullptr here:
>
>   status
>   marshall (connection *conn, const gcc_vbase_array *a)
>   {
>     size_t len;
>
>     if (a)
>       len = a->n_elements;
>     else
>       len = (size_t)-1;
>
>     if (!marshall_array_start (conn, 'v', len))
>       return FAIL;
>
>     if (!a)
>       return OK;
>    [...]
>
>
> So, I changed this code to use your suggestion and then also modified
> the final call:
>
>       result = instance->plugin ().start_class_type
> 	(name.get (), resuld, num_baseclasses > 0 ? &bases : nullptr,
> 	 filename, line);
>
> This didn't result in any test result changes, but I didn't look to see
> if this case is not tested or something like that.

Oh, I didn't realize that the change I proposed would change how we call
the function.  What you ended up doing makes sense, if that's what's the
compiler library expects.

Simon


More information about the Gdb-patches mailing list