Erik, thanks for the swift answer. Your right, I haven't seen any issues yet. But it a thought stroke me when implementing edit capabilities of FLAC vorbis comments. I've already implemented reading vorbis comments from FLAC files in 64-bit and it works without any issues. This now leave me a bit confused, since it should have issues(!). Using the MS 64-bit compiler on Windows 7/2008R2 64-bit. Static libFLAC compiled with compiler default 8 byte boundary alignment. Now consider this: typedef struct { FLAC__uint32 length; FLAC__byte *entry; } FLAC__StreamMetadata_VorbisComment_Entry; The compiler (with default settings) should interpret this as typedef struct { FLAC__uint32 length; uint32_t __padding; FLAC__byte *entry; } FLAC__StreamMetadata_VorbisComment_Entry; Sizeof structure: 32-bit - 8 bytes, 64-bit - 16 bytes How on earth does the compiler find entry correctly when reading (it does, but how)? What happens if I edit a vorbis comment/insert a new one when structure size is doubled? Am I missing something?
Erik de Castro Lopo
2011-May-30 07:20 UTC
[Flac-dev] 64-bit FLAC structure sizes and padding
Jerker B?ck wrote:> Erik, thanks for the swift answer. Your right, I haven't seen any issues > yet. But it a thought stroke me when implementing edit capabilities of FLAC > vorbis comments. I've already implemented reading vorbis comments from FLAC > files in 64-bit and it works without any issues. This now leave me a bit > confused, since it should have issues(!).No it shouldn't, at least not if FLAC was well designed and from everything I've seen, FLAC is well designed.> Using the MS 64-bit compiler on Windows 7/2008R2 64-bit. Static libFLAC > compiled with compiler default 8 byte boundary alignment. > > Now consider this: > > typedef struct { > FLAC__uint32 length; > FLAC__byte *entry; > } FLAC__StreamMetadata_VorbisComment_Entry; > > The compiler (with default settings) should interpret this as > > typedef struct { > FLAC__uint32 length; > uint32_t __padding; > FLAC__byte *entry; > } FLAC__StreamMetadata_VorbisComment_Entry; > > Sizeof structure: 32-bit - 8 bytes, 64-bit - 16 bytes > > How on earth does the compiler find entry correctly when reading (it does, > but how)?The compiler figures this out because the platform ABI [0] specifies how much padding there is and all compilers should follow the platform ABI. Furthermore, the structs above are *only* for communication between the client application and the library. Those structs are not actually used to store data in a FLAC file. HTH, Erik [0] https://secure.wikimedia.org/wikipedia/en/wiki/Application_binary_interface -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
Reasonably Related Threads
- 64-bit FLAC structure sizes and padding
- Patch to improve malformed vorbiscomment handling
- [PATCH] Add missing functions to VorbisComment class + a few other things
- Finding start of audio data using metadata level 2 interface.
- Patch to improve malformed vorbiscomment handling