This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: MI - Detecting change of string contents with variable objects


On Thu, Jan 04, 2007 at 05:13:36PM +1300, Nick Roberts wrote:
> I've probably done it the other way round to how you're asking (used
> value_get_print_value in c_value_of_variable) but, likewise, it involves
> re-use. 

Works out the same.  It looks reasonable to me.

>     struct type *type;
>   
> + 
>     /* The value of this expression or subexpression.  This may be NULL. 

Please try not to gratuitously move whitespace around (you
did this in a bunch of places).  I really appreciate that
when reviewing.

> ! 	      if (var->print_value)
> ! 		{
> ! 		  if (strcmp (var->print_value,
> ! 			      value_get_print_value (value, var->format)))
> ! 		    {
> ! 		      xfree (var->print_value);
> ! 		      var->print_value =
> ! 			xstrdup (value_get_print_value (value, var->format));
> ! 		      changed = 1;
> ! 		    }
> ! 		}
> ! 	      else
> ! 		var->print_value =
> ! 		  xstrdup (value_get_print_value (value, var->format));

value_get_print_value does a bunch of work, and returns a malloced
string.  So you should avoid calling it twice, and avoid leaking the
return value.

-- 
Daniel Jacobowitz
CodeSourcery


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]