Rob wrote: > You've got alignment issues here - msg will be aligned to support any > type (as malloc's interface specifies) so msg+1 will most likely be on > an odd address, one byte off a highly aligned address. This means if > your struct contains anything other than chars, you'll have UB. This is > fine on x86, which allows unaligned access with a performance penalty > but on something like an ARM machine you'll have issues. > > You probably want to memcpy the struct in from an existing one.
Heyho Rop, thanks for your feedback. What about declaring a struct for each message-type: struct msg_signed_data { unsigned int op; struct foo data; struct bar signature; }; This should also solve the alignment issues, or am I mistaken here? It also reduces the amount of memcpy. --Markus