I help my a workmate write a test program which is a apache module. She told me that there is a strange phenomenon, the size of data her program received is lager than the size of data my module sent out.
It is from word alignment. For example, there are two unsigned char data item. The CPU deals with them as
a word, four bytes, not two bytes. If they are filled 1, they must be followed two bytes zeros.
So, her program must deal with those surplus zeros.
The remainder work is fill lots of structures. I have to write many a function individullay for every
structure
It is from word alignment. For example, there are two unsigned char data item. The CPU deals with them as
a word, four bytes, not two bytes. If they are filled 1, they must be followed two bytes zeros.
So, her program must deal with those surplus zeros.
The remainder work is fill lots of structures. I have to write many a function individullay for every
structure
本文介绍了一位程序员帮助同事解决了一个奇怪的现象:接收的数据大小大于发送的数据大小的问题。原因是由于字节对齐导致的额外填充。文章还讨论了解决方案,包括如何处理这些多余的填充字节,并涉及到大量结构体的处理。
1328

被折叠的 条评论
为什么被折叠?



