Heyho,

since I did not find any suckless project regarding this issue, I would like to
ask you guys for some feedback:


unsigned char *msg;
size_t msg_size;
struct foo *msg_data;
struct bar *msg_signature;

msg_size = sizeof(unsigned char)        // op
        + sizeof(struct foo)    // data
        + sizeof(struct bar)    // signature
msg = malloc(msg_size);

*msg = MSG_OP_SIGNED_DATA;

msg_data = (struct foo *)(msg + 1);
msg_data->field0 = bla;
msg_data->field1 = blub;

msg_signature = (struct bar *)(msg_data + 1);
create_signature(msg, msg_signature);

sendmsg(msg);

free(msg);


I feel it is pretty good already compared to other message packing I've seen,
but do you know a way to make it suck even less?

--Markus

Reply via email to