Re: p = kmalloc(sizeof(*p), )
From: Miles Bader
Date: Tue Sep 20 2005 - 21:19:50 EST
Linus Torvalds <torvalds@xxxxxxxx> writes:
> Actually, some day that migth be a good idea, but at least historically,
> gcc has really really messed that kind of code up.
>
> Last I looked, depending on what the initializer was, gcc would create a
> temporary struct on the stack first, and then do a "memcpy()" of the
> result.
A little test shows:
gcc-3.4.4 seems to still do what you describe.
gcc-4.0.1 seems to it the "right" way (writing each field directly to
the destination structure).
Someday...
-miles
--
Yo mama's so fat when she gets on an elevator it HAS to go down.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/