lkml.org 
[lkml]   [2020]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/9] lib: string_helpers: provide kfree_strarray()
On Fri, Sep 25, 2020 at 01:32:01PM +0200, Bartosz Golaszewski wrote:
> On Fri, Sep 25, 2020 at 11:01 AM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > On Thu, Sep 24, 2020 at 01:38:34PM +0200, Bartosz Golaszewski wrote:
> > > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > >
> > > There's a common pattern of dynamically allocating an array of char
> > > pointers and then also dynamically allocating each string in this
> > > array. Provide a helper for freeing such a string array with one call.
> >
> > For consistency I would like to provide kalloc_strarray(), but it seems a bit
> > ambiguous. So I'm fine with this going alone.
> >
>
> But how would it even work - you can allocate strings in so many ways?

Yes, that's what I meant in the second part of the first sentence.

Something like:

static inline char **kalloc_strarray(n, gfp)
{
return kcalloc(n, sizeof(char *), gfp);
}

looks good enough, but it's only first part of the equation.

> Also: let's not introduce functions without users.

Agree.

--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2020-09-25 18:41    [W:0.054 / U:3.420 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site