[PATCH 2/4] remote: C++ify thread_item and threads_listing_context

Pedro Alves palves@redhat.com
Thu Nov 23 16:52:00 GMT 2017


On 11/23/2017 04:48 PM, Simon Marchi wrote:
> On 2017-11-23 09:22, Pedro Alves wrote:

>>> @@ -3109,37 +3105,28 @@ start_thread (struct gdb_xml_parser *parser,
>>>  {
>>
>>>    attr = xml_find_attribute (attributes, "name");
>>> -  item.name = attr != NULL ? xstrdup ((const char *) attr->value) :
>>> NULL;
>>> +  if (attr != NULL)
>>> +    item.name = (const char *) attr->value;
>>
>> Are you missing the xstrdup here?  I guess this is related to
>> the awkwardness you mentioned.
> 
> I don't think so, here item.name is an std::string, so the assignment
> does a copy.  This copy is required I think, because attr->value won't
> exist after we're done parsing the XML.
> 
>>> @@ -3150,8 +3137,8 @@ end_thread (struct gdb_xml_parser *parser,
>>>    struct threads_listing_context *data
>>>      = (struct threads_listing_context *) user_data;
>>>
>>> -  if (body_text && *body_text)
>>> -    VEC_last (thread_item_t, data->items)->extra = xstrdup (body_text);
>>> +  if (body_text != NULL && *body_text != '\0')
>>> +    data->items.back ().extra = body_text;
>>
>> And here?
> 
> Same, extra is an std::string.

Right, sorry, glanced over that too quickly.  :-P

Thanks,
Pedro Alves



More information about the Gdb-patches mailing list