Re: [PATCH i-g-t 1/3] stats: Allow the underlying arrays to grow at will

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jun 27, 2015 at 06:15:42PM +0100, Chris Wilson wrote:
> > +static void igt_stats_ensure_capacity(igt_stats_t *stats,
> > +				      unsigned int n_additional_values)
> > +{
> > +	unsigned int new_n_values = stats->n_values + n_additional_values;
> > +	unsigned int new_capacity;
> > +
> > +	if (new_n_values <= stats->capacity)
> > +		return;
> > +
> > +	new_capacity = get_new_capacity(new_n_values);
> > +	stats->values = realloc(stats->values,
> > +				sizeof(*stats->values) * new_capacity);
> > +	igt_assert(stats->values);
> > +
> > +	stats->capacity = new_capacity;
> > +
> > +	if (!stats->sorted)
> > +		return;
> > +
> > +	stats->sorted = realloc(stats->sorted,
> > +				sizeof(*stats->values) * new_capacity);
> > +	igt_assert(stats->sorted);
> 
> There isn't any point in preserving the sorted array when pushing new
> values. Might as well just free here and allocate again when required.

Indeed, push the whole thing so far with this change.

-- 
Damien
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux