lkml.org 
[lkml]   [2003]   [Sep]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [BK PATCH] One strdup() to rule them all
    On Mon, 25 August 2003 19:49:18 +0200, Andries Brouwer wrote:
    > On Mon, Aug 25, 2003 at 01:05:30PM -0400, Jeff Garzik wrote:
    >
    > > > > +char *strdup(const char *s)
    > > > > +{
    > > > > + char *rv = kmalloc(strlen(s)+1, GFP_KERNEL);
    > > > > + if (rv)
    > > > > + strcpy(rv, s);
    > > > > + return rv;
    > > > > +}
    >
    > > Unfortunately Linus doesn't like the strdup cleanup, so I don't see this
    > > patch going in either :)
    >
    > When seeing this my objection was: it introduces something with
    > a well-known name that uses GFP_KERNEL, so is not suitable everywhere -
    > an invitation to mistakes.

    Andries, would you still object this function?

    char *strdup(const char *s, int flags)
    {
    char *rv = kmalloc(strlen(s)+1, flags);
    if (rv)
    strcpy(rv, s);
    return rv;
    }

    strdup(foo, GFP_KERNEL) should give most people enough clue to know
    what they are doing.

    Jörn

    --
    But this is not to say that the main benefit of Linux and other GPL
    software is lower-cost. Control is the main benefit--cost is secondary.
    -- Bruce Perens
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:48    [W:0.039 / U:61.388 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site