[postgis-devel] getPoint_internal dangerous?

Paul Ramsey pramsey at cleverelephant.ca
Mon Mar 6 12:28:50 PST 2017


It's not a struct alignment thing (anymore) but there is a danger in
mutating the point array storage directly, because in the database context
it's not clear who owns it, and we've had problems in the past w/ functions
that directly write into the database storage. If you're going to be
changing data, the safest thing is always to take a copy at the start.

P.

On Mon, Mar 6, 2017 at 12:25 PM, Björn Harrtell <bjorn.harrtell at gmail.com>
wrote:

> I want to mutate one axis of the points in a POINTARRAY in the most
> efficient way.
>
> Something similar to ptarray_longitude_shift, see:
> https://github.com/postgis/postgis/blob/svn-trunk/
> liblwgeom/ptarray.c#L1393
>
> I see memcpy being used there and other places and afaik it has something
> to do with fears of struct misalignment.
>
> Does this mean I should most definitely not do this? :)
>
> POINT2D *p = (POINT2D *) getPoint_internal(pa, 0);
> p->y = extent - p->y;
>
> Regards,
> Björn
>
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20170306/60e6d6ad/attachment.html>


More information about the postgis-devel mailing list