From: John B. <joh...@gm...> - 2014-03-30 06:30:47
|
On Sat, Mar 29, 2014 at 10:58 PM, J Decker <d3...@gm...> wrote: > could note it on the documentation on the thing that uses the buffer 'must > be x bit aligned' It's an API intended to read a 32-bit (or 16-bit) quantity from a potentially misaligned buffer. Changing it so that it doesn't do what it's meant to do would be rather odd. chances are a normal alloc on a 32+ bit machine will be 32 bit aligned... > In libpng the APIs are used to read 32 or 16-bit quantities from chunks in the PNG memory stream. Since chunks can have odd lengths the quantities are mis-aligned 75% (32-bit) or 50% (16-bit) of the time. That's moot though, because what the code *actually* does is copy the four or two bytes to a *stack* buffer (potentially misaligned, depending on the compiler and the other locals in the function) then read the uint from that. John Bowler |