Re: [PATCH dwarves v6 1/3] gobuffer: Add gobuffer__sort() helper

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

 



On Wed, Apr 17, 2024 at 10:20:41AM +0100, Alan Maguire wrote:
> On 25/03/2024 17:53, Daniel Xu wrote:
> > Add a helper to sort the gobuffer. Trivial wrapper around qsort().
> > 
> > Signed-off-by: Daniel Xu <dxu@xxxxxxxxx>
> Reviewed-by: Alan Maguire <alan.maguire@xxxxxxxxxx>
> > ---
> >  gobuffer.c | 5 +++++
> >  gobuffer.h | 2 ++
> >  2 files changed, 7 insertions(+)
> > 
> > diff --git a/gobuffer.c b/gobuffer.c
> > index 02b2084..4655339 100644
> > --- a/gobuffer.c
> > +++ b/gobuffer.c
> > @@ -102,6 +102,11 @@ void gobuffer__copy(const struct gobuffer *gb, void *dest)
> >  	}
> >  }
> >  
> > +void gobuffer__sort(struct gobuffer *gb, unsigned int size, int (*compar)(const void *, const void *))
> > +{
> > +	qsort((void *)gb->entries, gb->nr_entries, size, compar);
> 
> nit shouldn't need to cast char * gb->entries to void * ; not worth
> respinning the series for though unless there are other issues

I can remove that while applying the series, which I'm doing now.

- Arnaldo
 
> > +}
> > +
> >  const void *gobuffer__compress(struct gobuffer *gb, unsigned int *size)
> >  {
> >  	z_stream z = {
> > diff --git a/gobuffer.h b/gobuffer.h
> > index a12c5c8..cd218b6 100644
> > --- a/gobuffer.h
> > +++ b/gobuffer.h
> > @@ -21,6 +21,8 @@ void __gobuffer__delete(struct gobuffer *gb);
> >  
> >  void gobuffer__copy(const struct gobuffer *gb, void *dest);
> >  
> > +void gobuffer__sort(struct gobuffer *gb, unsigned int size, int (*compar)(const void *, const void *));
> > +
> >  int gobuffer__add(struct gobuffer *gb, const void *s, unsigned int len);
> >  int gobuffer__allocate(struct gobuffer *gb, unsigned int len);
> >  




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux