Re: sizeof(struct ...)
- From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
- Date
- Nov 23, 2006, 17:57 UTC
- Message-ID
- <4565E0EC.4030709@lsrfire.ath.cx>
- In-Reply-To
- <4565CA02.20602@shadowen.org>
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.