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()?
This archive was generated by hypermail 2b29 : Wed Jan 15 2003 - 22:00:48 EST