[lkml]   [2003]   [Apr]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [TRIVIAL] kstrdup
    In message <> you write:
    > Rusty Trivial Russell wrote:
    > > +char *kstrdup(const char *s, int gfp)
    > > +{
    > > + char *buf = kmalloc(strlen(s)+1, gfp);
    > > + if (buf)
    > > + strcpy(buf, s);
    > > + return buf;
    > > +}
    > You should save the strlen result to a temp var, and then s/strcpy/memcpy/

    Completely disagree. Write the most straightforward code possible,
    and then if there proves to be a problem, optimize. Optimizations
    where there's no actual performance problem should be left to the

    Case in point: gcc-3.2 on -O2 on Intel is one instruction longer for
    your version.

    Hope that helps,
    Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

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