lkml.org 
[lkml]   [2003]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH] [TRIVIAL] kstrdup
    From
    Date
    On Tue, 14 Jan 2003 12:55:40 +1100, Rusty Russell said:
    > Everyone loves reimplementing strdup.

    > +char *kstrdup(const char *s, int gfp)
    > +{
    > + char *buf = kmalloc(strlen(s)+1, gfp);
    > + if (buf)
    > + strcpy(buf, s);
    > + return buf;
    > +}

    Out of curiosity, who's job is it to avoid the race condition between when
    this function takes the strlen() and the other processor makes it a longer
    string before we return from kmalloc() and do the strcpy()?

    [unhandled content-type:application/pgp-signature]
    \
     
     \ /
      Last update: 2005-03-22 13:32    [W:0.019 / U:30.328 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site