Re: sizeof(struct ...)
From: René Scharfe <hidden>
Date: 2016-08-11 19:40:47
Andy Whitcroft schrieb:
Perhaps we can look and see what a portable application like gzip or bzip2 do in this situation. They must have the same problem.
Info-ZIP's zip uses structs only for in-memory storage and has a write function for each of them that writes the members one by one. I find the structs in archive-zip.c easier to read, but I might be biased. ;-) Anyway, archive-zip.c assumes that there is no padding between unsigned char arrays and that an unsigned char is exactly one byte wide. The additional current assumption -- that sizeof(struct ...) sums up the sizes of all struct members -- is wrong on ARM, and the patches in this thread correct this error. So we're not as portable as Info-ZIP, but I think the assumptions above hold true for all interesting architectures. And we have a readable description of the on-disk ZIP file headers.