Re: p = kmalloc(sizeof(*p), )

Miles Bader
2005-09-21T02:19:20Z

Linus Torvalds <torvalds@osdl.org> 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.