[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0alpha1-45-g079e807
git at osgeo.org
git at osgeo.org
Mon Mar 23 02:58:14 PDT 2020
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".
The branch, master has been updated
via 079e807123b8086f05416bba82305151df8a0ff0 (commit)
from 33cd9fba44bc5b204b22a4b4eb6d56006b38637a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 079e807123b8086f05416bba82305151df8a0ff0
Author: Raúl Marín <git at rmr.ninja>
Date: Fri Mar 20 20:33:42 2020 +0100
Use offsetof instead of pointer arithmetics
I introduced this montrosity in #4451 because I didn't know any better
Closes https://github.com/postgis/postgis/pull/549
diff --git a/liblwgeom/gserialized1.c b/liblwgeom/gserialized1.c
index 4b16aaa..728c005 100644
--- a/liblwgeom/gserialized1.c
+++ b/liblwgeom/gserialized1.c
@@ -29,6 +29,8 @@
#include "lwgeodetic.h"
#include "gserialized1.h"
+#include <stddef.h>
+
/***********************************************************************
* GSERIALIZED metadata utility functions.
*/
@@ -113,9 +115,8 @@ int gserialized1_is_geodetic(const GSERIALIZED *gser)
uint32_t gserialized1_max_header_size(void)
{
- static const intptr_t size_of_gserialized_up_to_data = (intptr_t) & ((GSERIALIZED *)NULL)->data;
/* GSERIALIZED size + max bbox according gbox_serialized_size (XYZM*2) + extended flags + type */
- return size_of_gserialized_up_to_data + 8 * sizeof(float) + sizeof(uint32_t);
+ return offsetof(GSERIALIZED, data) + 8 * sizeof(float) + sizeof(uint32_t);
}
static uint32_t gserialized1_header_size(const GSERIALIZED *gser)
diff --git a/liblwgeom/gserialized2.c b/liblwgeom/gserialized2.c
index da6adb8..7967704 100644
--- a/liblwgeom/gserialized2.c
+++ b/liblwgeom/gserialized2.c
@@ -47,6 +47,8 @@
#include "lwgeodetic.h"
#include "gserialized2.h"
+#include <stddef.h>
+
/***********************************************************************
* GSERIALIZED metadata utility functions.
*/
@@ -175,9 +177,8 @@ int gserialized2_is_geodetic(const GSERIALIZED *g)
uint32_t gserialized2_max_header_size(void)
{
- static const intptr_t size_of_gserialized_up_to_data = (intptr_t) & ((GSERIALIZED *)NULL)->data;
/* GSERIALIZED size + max bbox according gbox_serialized_size (XYZM*2) + extended flags + type */
- return size_of_gserialized_up_to_data + 8 * sizeof(float) + sizeof(uint64_t) + sizeof(uint32_t);
+ return offsetof(GSERIALIZED, data) + 8 * sizeof(float) + sizeof(uint64_t) + sizeof(uint32_t);
}
-----------------------------------------------------------------------
Summary of changes:
liblwgeom/gserialized1.c | 5 +++--
liblwgeom/gserialized2.c | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list