for copying structs, for most compilers, this seems like a "more likely correct" solution (ex: if memcpy is handled poorly, ...).
-
-
Replying to @cr88192 @RichFelker
Yes, exactly. Unfortunately C doesn't have struct assignment by value, which is a shame. Feels like a C-y operation to me and not C++-like.
1 reply 0 retweets 0 likes -
Replying to @sortiecat @cr88192
Huh? Of course C has struct assignment by value.
1 reply 0 retweets 1 like -
Replying to @RichFelker @cr88192
Huh. You're right. Not sure where I got this impression from. Yay. Though C doesn't have struct == so my memcmp concerns still exist.
2 replies 0 retweets 1 like -
Replying to @sortiecat @cr88192
Yes. But memcmp for structs is often wrong unless you know they have no padding, & no members that need comparison more nuanced than memcmp.
1 reply 0 retweets 1 like -
Replying to @RichFelker @cr88192
I continue to be terrified of bugs relating to uninitialized padding and struct uninitialized padding copied between security boundaries
1 reply 1 retweet 2 likes -
Replying to @sortiecat @cr88192
This is a strong argument for not copying structs at all but just assigning individual members.
1 reply 0 retweets 2 likes -
Replying to @RichFelker @cr88192
struct foo a = b; struct foo a = { 0 }; a.baz = b.baz; a.qux = b.qux; Much more boilerplate. :/
2 replies 0 retweets 1 like -
Replying to @sortiecat @cr88192
Yes but it forces you to consciously marshal across priv domains rather than treating them as having shared/shareable data structs.
1 reply 0 retweets 2 likes -
Also helps avoid creating ABI dependency on internal representations of one side.
2 replies 0 retweets 0 likes
Rather than writing the "boilerplate" code you can use tables to represent the layout & generic code to do the marshalling using them.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.