From 290717e5645365bb93273f231a9bb10b29cb0f96 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Sun, 9 Jan 2005 20:28:59 +0000 Subject: [PATCH] size_t usage cleanups. git-svn-id: http://svn.osgeo.org/postgis/trunk@1262 b70326c6-7e19-0410-871a-916f4a2858ee --- lwgeom/liblwgeom.h | 6 +++--- lwgeom/lwcollection.c | 4 ++-- lwgeom/lwgeom_api.c | 19 ++++++++++--------- lwgeom/lwgeom_functions_basic.c | 30 +++++++++++++++--------------- 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/lwgeom/liblwgeom.h b/lwgeom/liblwgeom.h index decb3a1e6..3d01208c6 100644 --- a/lwgeom/liblwgeom.h +++ b/lwgeom/liblwgeom.h @@ -605,7 +605,7 @@ extern LWGEOM_EXPLODED *lwgeom_explode(char *serialized); * Return the length of the serialized form corresponding * to this exploded structure. */ -extern uint32 lwexploded_findlength(LWGEOM_EXPLODED *exp, int wantbbox); +extern size_t lwexploded_findlength(LWGEOM_EXPLODED *exp, int wantbbox); // Serialize an LWGEOM_EXPLODED object. // SRID and ndims will be taken from exploded structure. @@ -687,8 +687,8 @@ extern char *lwgeom_serialized_construct(int SRID, int finalType, char hasz, cha // construct the empty geometry (GEOMETRYCOLLECTION(EMPTY)) extern char *lwgeom_constructempty(int SRID, char hasz, char hasm); -extern void lwgeom_constructempty_buf(int SRID, char hasz, char hasm, char *buf, int *size); -int lwgeom_empty_length(int SRID); +extern void lwgeom_constructempty_buf(int SRID, char hasz, char hasm, char *buf, size_t *size); +size_t lwgeom_empty_length(int SRID); // get the SRID from the LWGEOM // none present => -1 diff --git a/lwgeom/lwcollection.c b/lwgeom/lwcollection.c index 1c1ad36db..7fe33e678 100644 --- a/lwgeom/lwcollection.c +++ b/lwgeom/lwcollection.c @@ -141,8 +141,8 @@ lwcollection_serialize_size(LWCOLLECTION *col) void lwcollection_serialize_buf(LWCOLLECTION *coll, char *buf, size_t *retsize) { - int size=1; // type - int subsize=0; + size_t size=1; // type + size_t subsize=0; char hasSRID; char *loc; int i; diff --git a/lwgeom/lwgeom_api.c b/lwgeom/lwgeom_api.c index 290ddce9a..46cb166b6 100644 --- a/lwgeom/lwgeom_api.c +++ b/lwgeom/lwgeom_api.c @@ -1273,7 +1273,7 @@ lwgeom_constructempty(int SRID, char hasz, char hasm) return result; } -int +size_t lwgeom_empty_length(int SRID) { int size = 5; @@ -1284,7 +1284,8 @@ lwgeom_empty_length(int SRID) // construct the empty geometry (GEOMETRYCOLLECTION(EMPTY)) // writing it into the provided buffer. void -lwgeom_constructempty_buf(int SRID, char hasz, char hasm, char *buf, int *retsize) +lwgeom_constructempty_buf(int SRID, char hasz, char hasm, + char *buf, size_t *retsize) { int ngeoms = 0; @@ -2172,8 +2173,8 @@ lwexploded_sum(LWGEOM_EXPLODED *exp1, LWGEOM_EXPLODED *exp2) char * lwexploded_serialize(LWGEOM_EXPLODED *exploded, int wantbbox) { - int sizecom = 0; - int size; + size_t sizecom = 0; + size_t size; char *result; size = lwexploded_findlength(exploded, wantbbox); @@ -2328,7 +2329,7 @@ lwexploded_serialize_buf(LWGEOM_EXPLODED *exploded, int wantbbox, // Serialize points stripping BBOX and SRID if any for (i=0; inpoints; i++) { - int subsize; + size_t subsize; point = lwpoint_deserialize(exploded->points[i]); point->SRID = -1; lwpoint_serialize_buf(point, loc, &subsize); @@ -2349,7 +2350,7 @@ lwexploded_serialize_buf(LWGEOM_EXPLODED *exploded, int wantbbox, // Serialize lines stripping BBOX and SRID if any for (i=0; inlines; i++) { - int subsize; + size_t subsize; line = lwline_deserialize(exploded->lines[i]); if ( line == NULL ) @@ -2376,7 +2377,7 @@ lwexploded_serialize_buf(LWGEOM_EXPLODED *exploded, int wantbbox, // Serialize polys stripping BBOX and SRID if any for (i=0; inpolys; i++) { - int subsize; + size_t subsize; poly = lwpoly_deserialize(exploded->polys[i]); if ( poly == NULL ) @@ -2444,10 +2445,10 @@ checkexplodedsize(char *srl, LWGEOM_EXPLODED *exp, int alloced, char wantbbox) } #endif -uint32 +size_t lwexploded_findlength(LWGEOM_EXPLODED *exploded, int wantbbox) { - uint32 size=0; + size_t size=0; char ntypes=0; uint32 i; diff --git a/lwgeom/lwgeom_functions_basic.c b/lwgeom/lwgeom_functions_basic.c index 83d05ff36..4da8c2fa5 100644 --- a/lwgeom/lwgeom_functions_basic.c +++ b/lwgeom/lwgeom_functions_basic.c @@ -64,8 +64,8 @@ PG_FUNCTION_INFO_V1(LWGEOM_mem_size); Datum LWGEOM_mem_size(PG_FUNCTION_ARGS) { PG_LWGEOM *geom = (PG_LWGEOM *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); - int32 size = geom->size; - int32 computed_size = lwgeom_size(SERIALIZED_FORM(geom)); + size_t size = geom->size; + size_t computed_size = lwgeom_size(SERIALIZED_FORM(geom)); computed_size += 4; // varlena size if ( size != computed_size ) { @@ -480,8 +480,8 @@ lwgeom_force2d_recursive(char *serialized, char *optr, size_t *retsize) { LWGEOM_INSPECTED *inspected; int i; - int totsize=0; - int size=0; + size_t totsize=0; + size_t size=0; int type; LWPOINT *point = NULL; LWLINE *line = NULL; @@ -598,8 +598,8 @@ lwgeom_force3dz_recursive(char *serialized, char *optr, size_t *retsize) { LWGEOM_INSPECTED *inspected; int i,j,k; - int totsize=0; - int size=0; + size_t totsize=0; + size_t size=0; int type; LWPOINT *point = NULL; LWLINE *line = NULL; @@ -759,8 +759,8 @@ lwgeom_force3dm_recursive(unsigned char *serialized, char *optr, size_t *retsize { LWGEOM_INSPECTED *inspected; int i,j,k; - int totsize=0; - int size=0; + size_t totsize=0; + size_t size=0; int type; unsigned char newtypefl; LWPOINT *point = NULL; @@ -975,8 +975,8 @@ lwgeom_force4d_recursive(char *serialized, char *optr, size_t *retsize) { LWGEOM_INSPECTED *inspected; int i,j,k; - int totsize=0; - int size=0; + size_t totsize=0; + size_t size=0; int type; LWPOINT *point = NULL; LWLINE *line = NULL; @@ -1132,7 +1132,7 @@ Datum LWGEOM_force_2d(PG_FUNCTION_ARGS) { PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); PG_LWGEOM *result; - int32 size = 0; + size_t size = 0; // already 2d if ( lwgeom_ndims(geom->type) == 2 ) PG_RETURN_POINTER(geom); @@ -1159,7 +1159,7 @@ Datum LWGEOM_force_3dz(PG_FUNCTION_ARGS) PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); PG_LWGEOM *result; int olddims; - int32 size = 0; + size_t size = 0; olddims = lwgeom_ndims(geom->type); @@ -1234,7 +1234,7 @@ Datum LWGEOM_force_4d(PG_FUNCTION_ARGS) PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); PG_LWGEOM *result; int olddims; - int32 size = 0; + size_t size = 0; olddims = lwgeom_ndims(geom->type); @@ -1263,7 +1263,7 @@ Datum LWGEOM_force_collection(PG_FUNCTION_ARGS) PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); PG_LWGEOM *result; int oldtype; - int32 size = 0; + size_t size = 0; char *iptr, *optr; int32 nsubgeoms = 1; @@ -1340,7 +1340,7 @@ Datum LWGEOM_force_multi(PG_FUNCTION_ARGS) PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); PG_LWGEOM *result; int oldtype, newtype; - int32 size = 0; + size_t size = 0; char *iptr, *optr; int32 nsubgeoms = 1; -- 2.40.0