Re: 4 byte length storage
Ruben Safir <ruben-v1XHP5QhJixWk0Htik3J/[email protected]>
| Newsgroups | gmane.comp.graphics.png.devel |
|---|---|
| Message-ID | <[email protected]> |
So now I have a question about the data in the IDAT chuncks. do they likiwise need to be reversed in the byte order before sending them to be decompressed with zlib? On 12/06/2016 12:32 PM, John Bowler wrote: > On Tue, Dec 6, 2016 at 8:55 AM, Andreas Kleinert > <[email protected]> wrote: >> I have not really checked your code in detail, but are you sure it is not just big vs. little endian conversion...?! > > That's why '13' (0x0000000D) appears as 218103808 (0x0D000000), but > there are other issues in the code that are perhaps best covered by an > online tutorial such as this one: > > https://isocpp.org/wiki/faq/serialization > > (That's C++ specific). > > One issue is that the code relies on uint32_t being a four byte > quantity, CHUNK is a typedef of uint32_t: > > char * cur = get_index(); > CHUNK * tmp = reinterpret_cast<CHUNK *>(cur); > > Certainly uint32_t is required to have exactly 32 bits and therefore > behave as a 32-bit value for modular arithmetic (per the ANSI C spec), > however I don't know that the representation is constrained to be 4 > bytes. I would be surprised if C89 (which formalized the type) had > done that and so far as I can see the above code has undefined > behavior. > > The general rule for serialization is to either use well-defined > primitives or to do it yourself; the code is not exactly difficult to > write, though it can be difficult to get right sometimes ;-) > > John Bowler > > ------------------------------------------------------------------------------ > Developer Access Program for Intel Xeon Phi Processors > Access to Intel Xeon Phi processor-based developer platforms. > With one year of Intel Parallel Studio XE. > Training and support from Colfax. > Order your platform today.http://sdm.link/xeonphi > _______________________________________________ > png-mng-implement mailing list > png-mng-implement-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > https://lists.sourceforge.net/lists/listinfo/png-mng-implement > -- So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com Being so tracked is for FARM ANIMALS and and extermination camps, but incompatible with living as a free human being. -RI Safir 2013 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot