[postgis-devel] getPoint_internal dangerous?
Björn Harrtell
bjorn.harrtell at gmail.com
Mon Mar 6 12:35:51 PST 2017
Ok I see, I didn't realize I was this close to the database storage/cache.
But then I fail to see how a memcpy straight into the pointer of
a getPoint_internal can be any better? This is done all over the place.
/Björn
2017-03-06 21:28 GMT+01:00 Paul Ramsey <pramsey at cleverelephant.ca>:
> 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/90ffaafa/attachment.html>
More information about the postgis-devel
mailing list