[postgis-devel] getPoint aligned/unaligned reads

Paul Ramsey pramsey at cleverelephant.ca
Sun Sep 26 13:01:56 PDT 2021



> On Sep 26, 2021, at 11:32 AM, Sandro Santilli <strk at kbt.io> wrote:
> 
> I must have lost track but.. is POINTARRAY nowadays ensured to always
> be double-aligned or not ? I'm asking because of issue #4990 which
> reveals some problem on 32bit and I suspect (but didn't confirm yet)
> that it may be due to using the getPoint_cp function, which does
> the cast from char* to double*...

Since 2.0 the underlying double array in a POINTARRAY is double aligned, which is the reason getPoint2d_cp() works at all on platforms that disallow unaligned access (hard to find those nowadays though).

> Paul: as the last one who touched the serialization format, is it
> always safe to use getPoint_cp or not, to your knowledge ?

It is always safe, the serialization is carefully set up to retain double alignment of the double arrays.

P

> 
> --strk; 
> 
>  Libre GIS consultant/developer
>  https://strk.kbt.io/services.html



More information about the postgis-devel mailing list