[igt-dev] [PATCH i-g-t 1/3] lib/vec: Add igt_vec

Chris Wilson chris at chris-wilson.co.uk
Thu Jan 30 16:00:24 UTC 2020


Quoting Ville Syrjälä (2020-01-30 15:54:10)
> On Thu, Jan 30, 2020 at 03:31:41PM +0000, Chris Wilson wrote:
> > Quoting Ville Syrjala (2020-01-30 15:12:27)
> > > +#ifndef __IGT_VEC_H__
> > > +#define __IGT_VEC_H__
> > > +
> > > +struct igt_vec {
> > > +       void *elems;
> > > +       int elem_size, size, len;
> > 
> > I would have used char[0] and casting just to have a variable length
> > struct :)
> 
> Then we'd have to reallocate the whole struct to grow it.
> Wouldn't work since the caller owns the struct.

True.

> > 
> > I might have also used longs throughout instead of ints, or in this day
> > and age, size_t.
> 
> I was actually thinking of something smaller since I doubt anyone
> wants to use this with large amounts of data due to O(n).

Heh, I was thinking of combining this with the igt_collections elsewhere
for random set permutations. Both API are not so keen with my idea of
testing everything under the sun at once. Self-mutating test sets?
-Chris


More information about the igt-dev mailing list