Messages in this thread | | | Date | Mon, 13 Jan 2003 22:19:21 -0500 | From | Jeff Garzik <> | Subject | Re: [PATCH] [TRIVIAL] kstrdup |
| |
On Tue, Jan 14, 2003 at 12:55:40PM +1100, Rusty Russell wrote: > + > +char *kstrdup(const char *s, int gfp) > +{ > + char *buf = kmalloc(strlen(s)+1, gfp); > + if (buf) > + strcpy(buf, s); > + return buf; > +}
Poo -- why not store the length in a temp, since the compiler does it behind the scenes anyway, and then memcpy instead of strcpy? (remember to store the +1 too, since you want to memcpy the null...)
Jeff
- 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/
| |