[RFA 01/12] Introduce a gdb_ref_ptr specialization for struct value

Pedro Alves palves@redhat.com
Fri Apr 6 19:29:00 GMT 2018


On 04/05/2018 10:14 PM, Tom Tromey wrote:
> struct value is internally reference counted and so, while it also has
> some ownership rules unique to it, it makes sense to use a gdb_ref_ptr
> when managing it automatically.
> 
> This patch removes the existing unique_ptr specialization in favor of
> a reference-counted pointer.  It also introduces two other
> clarifications:
> 
> 1. Rename value_free to value_decref, which I think is more in line
>    with what the function actually does; and
> 
> 2. Change release_value to return a gdb_ref_ptr.  This change allows
>    us to remove the confusing release_value_or_incref function,
>    primarily by making it much simpler to reason about the result of
>    release_value.

Yeah.  As I was reading this patch, I was wondering whether 
release_value is going to score high in could-use-a-better-name
charts.  I.e., wondering whether code like this:

	release_value (v).release ();

is likely to cause confusion.  

Maybe renaming it to be a bit more explicit would help.

E.g.:
	release_from_value_chain (v).release ();
or:
	move_out_of_value_chain (v).release ();

But, the following patches eliminate the ".release()" calls, so
it isn't that bad.  Anyway, that was a thought for another rainy
day, not for this patch.

Thanks,
Pedro Alves



More information about the Gdb-patches mailing list