]> granicus.if.org Git - postgis/commitdiff
Changed 'char' to 'uchar' (unsigned char typedef) wherever octet is actually
authorSandro Santilli <strk@keybit.net>
Thu, 10 Feb 2005 10:52:53 +0000 (10:52 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 10 Feb 2005 10:52:53 +0000 (10:52 +0000)
meant to be.

git-svn-id: http://svn.osgeo.org/postgis/trunk@1390 b70326c6-7e19-0410-871a-916f4a2858ee

17 files changed:
lwgeom/liblwgeom.h
lwgeom/lwcollection.c
lwgeom/lwgeom.c
lwgeom/lwgeom_api.c
lwgeom/lwgeom_chip.c
lwgeom/lwgeom_estimate.c
lwgeom/lwgeom_functions_basic.c
lwgeom/lwgeom_inout.c
lwgeom/lwgeom_ogc.c
lwgeom/lwline.c
lwgeom/lwmline.c
lwgeom/lwmpoint.c
lwgeom/lwmpoly.c
lwgeom/lwpoint.c
lwgeom/lwpoly.c
lwgeom/measures.c
lwgeom/ptarray.c

index 3d01208c6ef68c97c469b0ed80cc924cbc6ed682..2fd9ce6e992e667361d382f399379a3f819987a3 100644 (file)
@@ -35,6 +35,8 @@ extern lwreporter lwnotice;
 
 //-----------------------------------------------------------------
 
+typedef unsigned char uchar;
+
 typedef struct
 {
        float xmin;
@@ -137,10 +139,12 @@ typedef struct
 // DONT MIX 2D and 3D POINTS!  *EVERYTHING* is either one or the other
 typedef struct
 {
-    char  *serialized_pointlist; // array of POINT 2D, 3D or 4D.
-                                // probably missaligned.
-                                // points to a double
-    unsigned char  dims;        // use TYPE_* macros to handle
+    /* array of POINT 2D, 3D or 4D. probably missaligned. */
+    uchar *serialized_pointlist;
+
+    /* use TYPE_* macros to handle */
+    uchar  dims;
+
     uint32 npoints;
 }  POINTARRAY;
 
@@ -149,7 +153,7 @@ typedef struct
 // LWGEOM (any type)
 typedef struct
 {
-       unsigned char type; 
+       uchar type; 
        BOX2DFLOAT4 *bbox;
        uint32 SRID; // -1 == unneeded
        void *data;
@@ -158,7 +162,7 @@ typedef struct
 // POINTYPE
 typedef struct
 {
-       unsigned char type; // POINTTYPE
+       uchar type; // POINTTYPE
        BOX2DFLOAT4 *bbox;
        uint32 SRID;    
        POINTARRAY *point;  // hide 2d/3d (this will be an array of 1 point)
@@ -167,7 +171,7 @@ typedef struct
 // LINETYPE
 typedef struct
 {
-       unsigned char type; // LINETYPE
+       uchar type; // LINETYPE
        BOX2DFLOAT4 *bbox;
        uint32 SRID;    
        POINTARRAY    *points; // array of POINT3D
@@ -176,7 +180,7 @@ typedef struct
 // POLYGONTYPE
 typedef struct
 {
-       unsigned char type; // POLYGONTYPE
+       uchar type; // POLYGONTYPE
        BOX2DFLOAT4 *bbox;
        uint32 SRID;    
        int  nrings;
@@ -186,7 +190,7 @@ typedef struct
 // MULTIPOINTTYPE
 typedef struct
 {
-       unsigned char type; 
+       uchar type; 
        BOX2DFLOAT4 *bbox;
        uint32 SRID;    
        int  ngeoms;
@@ -196,7 +200,7 @@ typedef struct
 // MULTILINETYPE
 typedef struct
 {  
-       unsigned char type; 
+       uchar type; 
        BOX2DFLOAT4 *bbox;
        uint32 SRID;    
        int  ngeoms;
@@ -206,7 +210,7 @@ typedef struct
 // MULTIPOLYGONTYPE
 typedef struct
 {  
-       unsigned char type; 
+       uchar type; 
        BOX2DFLOAT4 *bbox;
        uint32 SRID;    
        int  ngeoms;
@@ -216,7 +220,7 @@ typedef struct
 // COLLECTIONTYPE
 typedef struct
 {   
-       unsigned char type; 
+       uchar type; 
        BOX2DFLOAT4 *bbox;
        uint32 SRID;    
        int  ngeoms;
@@ -295,7 +299,7 @@ extern int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point);
 // You'll need to cast it to appropriate dimensioned point.
 // Note that if you cast to a higher dimensional point you'll
 // possibly corrupt the POINTARRAY.
-extern char *getPoint(const POINTARRAY *pa, int n);
+extern uchar *getPoint(const POINTARRAY *pa, int n);
 //--- here is a macro equivalent, for speed...
 //#define getPoint(x,n) &( (x)->serialized_pointlist[((x)->ndims*8)*(n)] )
 
@@ -304,7 +308,7 @@ extern char *getPoint(const POINTARRAY *pa, int n);
 // NOTE: points is *not* copied, so be careful about modification (can be aligned/missaligned)
 // NOTE: hasz and hasm are descriptive - it describes what type of data
 //      'points' points to.  No data conversion is done.
-extern POINTARRAY *pointArray_construct(char *points, char hasz, char hasm, uint32 npoints);
+extern POINTARRAY *pointArray_construct(uchar *points, char hasz, char hasm, uint32 npoints);
 
 //calculate the bounding box of a set of points
 // returns a 3d box
@@ -366,16 +370,16 @@ extern int pointArray_ptsize(const POINTARRAY *pa);
 #define TYPE_GETTYPE(t) ((t)&0x0F)
 #define TYPE_GETZM(t) (((t)&0x30)>>4)
 
-extern char lwgeom_hasBBOX(unsigned char type); // true iff B bit set
-extern int  lwgeom_ndims(unsigned char type);   // returns 2,3 or 4
-extern int  lwgeom_hasZ(unsigned char type);    // has Z ?
-extern int  lwgeom_hasM(unsigned char type);    // has M ?
-extern int  lwgeom_getType(unsigned char type); // returns the tttt value
+extern char lwgeom_hasBBOX(uchar type); // true iff B bit set
+extern int  lwgeom_ndims(uchar type);   // returns 2,3 or 4
+extern int  lwgeom_hasZ(uchar type);    // has Z ?
+extern int  lwgeom_hasM(uchar type);    // has M ?
+extern int  lwgeom_getType(uchar type); // returns the tttt value
 
-extern unsigned char lwgeom_makeType(char hasZ, char hasM, char hasSRID, int type);
-extern unsigned char lwgeom_makeType_full(char hasZ, char hasM, char hasSRID, int type, char hasBBOX);
-extern char lwgeom_hasSRID(unsigned char type); // true iff S bit is set
-extern char lwgeom_hasBBOX(unsigned char type); // true iff B bit set
+extern uchar lwgeom_makeType(char hasZ, char hasM, char hasSRID, int type);
+extern uchar lwgeom_makeType_full(char hasZ, char hasM, char hasSRID, int type, char hasBBOX);
+extern char lwgeom_hasSRID(uchar type); // true iff S bit is set
+extern char lwgeom_hasBBOX(uchar type); // true iff B bit set
 
 
 
@@ -385,9 +389,9 @@ extern char lwgeom_hasBBOX(unsigned char type); // true iff B bit set
  */
 typedef struct {
        uint32 size;
-       unsigned char type; // encodes ndims, type, bbox presence,
+       uchar type; // encodes ndims, type, bbox presence,
                            // srid presence
-       char data[1];
+       uchar data[1];
 } PG_LWGEOM;
 
 /*
@@ -399,12 +403,12 @@ typedef struct {
  * If you request bbox (wantbbox=1) it will be extracted or computed
  * from the serialized form.
  */
-extern PG_LWGEOM *PG_LWGEOM_construct(char *serialized, int SRID, int wantbbox);
+extern PG_LWGEOM *PG_LWGEOM_construct(uchar *serialized, int SRID, int wantbbox);
 
 /*
  * Compute bbox of serialized geom
  */
-extern int compute_serialized_bbox_p(char *serialized_form, BOX2DFLOAT4 *box);
+extern int compute_serialized_bbox_p(uchar *serialized_form, BOX2DFLOAT4 *box);
 
 
 /*
@@ -412,7 +416,7 @@ extern int compute_serialized_bbox_p(char *serialized_form, BOX2DFLOAT4 *box);
  * caching a bbox
  */
 char is_worth_caching_pglwgeom_bbox(const PG_LWGEOM *);
-char is_worth_caching_serialized_bbox(const char *);
+char is_worth_caching_serialized_bbox(const uchar *);
 char is_worth_caching_lwgeom_bbox(const LWGEOM *);
 
 /*
@@ -420,18 +424,18 @@ char is_worth_caching_lwgeom_bbox(const LWGEOM *);
  * by most functions from an PG_LWGEOM struct.
  * (which is an PG_LWGEOM w/out int32 size casted to char *)
  */
-#define SERIALIZED_FORM(x) ((char *)(x))+4
+#define SERIALIZED_FORM(x) ((uchar *)(x))+4
 
 
 /*
  * This function computes the size in bytes
  * of the serialized geometries.
  */
-extern size_t lwgeom_size(const char *serialized_form);
-extern size_t lwgeom_size_subgeom(const char *serialized_form, int geom_number);
-extern size_t lwgeom_size_line(const char *serialized_line);
-extern size_t lwgeom_size_point(const char *serialized_point);
-extern size_t lwgeom_size_poly(const char *serialized_line);
+extern size_t lwgeom_size(const uchar *serialized_form);
+extern size_t lwgeom_size_subgeom(const uchar *serialized_form, int geom_number);
+extern size_t lwgeom_size_line(const uchar *serialized_line);
+extern size_t lwgeom_size_point(const uchar *serialized_point);
+extern size_t lwgeom_size_poly(const uchar *serialized_line);
 
 
 //--------------------------------------------------------
@@ -445,17 +449,17 @@ extern size_t lwgeom_size_poly(const char *serialized_line);
 // serialized_form should point to the 8bit type format (with type = 1)
 // Returns NULL if serialized form is not a point.
 // See serialized form doc
-extern LWPOINT *lwpoint_deserialize(char *serialized_form);
+extern LWPOINT *lwpoint_deserialize(uchar *serialized_form);
 
 // Find size this point would get when serialized (no BBOX)
 extern size_t lwpoint_serialize_size(LWPOINT *point);
 
 // convert this point into its serialize form
 // result's first char will be the 8bit type.  See serialized form doc
-extern char  *lwpoint_serialize(LWPOINT *point);
+extern uchar *lwpoint_serialize(LWPOINT *point);
 
 // same as above, writes to buf
-extern void lwpoint_serialize_buf(LWPOINT *point, char *buf, size_t *size);
+extern void lwpoint_serialize_buf(LWPOINT *point, uchar *buf, size_t *size);
 
 // find bounding box (standard one)  zmin=zmax=0 if 2d (might change to NaN)
 extern BOX3D *lwpoint_findbbox(LWPOINT *point);
@@ -473,7 +477,7 @@ extern int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out);
 // construct a proper LWLINE.
 // serialized_form should point to the 8bit type format (with type = 2)
 // See serialized form doc
-extern LWLINE *lwline_deserialize(char *serialized_form);
+extern LWLINE *lwline_deserialize(uchar *serialized_form);
 
 // find the size this line would get when serialized (no BBOX)
 extern size_t lwline_serialize_size(LWLINE *line);
@@ -481,10 +485,10 @@ extern size_t lwline_serialize_size(LWLINE *line);
 // convert this line into its serialize form
 // result's first char will be the 8bit type.  See serialized form doc
 // copies data.
-extern char  *lwline_serialize(LWLINE *line);
+extern uchar *lwline_serialize(LWLINE *line);
 
 // same as above, writes to buf
-extern void lwline_serialize_buf(LWLINE *line, char *buf, size_t *size);
+extern void lwline_serialize_buf(LWLINE *line, uchar *buf, size_t *size);
 
 // find bounding box (standard one)  zmin=zmax=0 if 2d (might change to NaN)
 extern BOX3D *lwline_findbbox(LWLINE *line);
@@ -496,7 +500,7 @@ extern BOX3D *lwline_findbbox(LWLINE *line);
 // construct a proper LWPOLY.
 // serialized_form should point to the 8bit type format (with type = 3)
 // See serialized form doc
-extern LWPOLY *lwpoly_deserialize(char *serialized_form);
+extern LWPOLY *lwpoly_deserialize(uchar *serialized_form);
 
 // find the size this polygon would get when serialized (no bbox!)
 extern size_t lwpoly_serialize_size(LWPOLY *poly);
@@ -504,10 +508,10 @@ extern size_t lwpoly_serialize_size(LWPOLY *poly);
 // create the serialized form of the polygon
 // result's first char will be the 8bit type.  See serialized form doc
 // points copied
-extern char *lwpoly_serialize(LWPOLY *poly);
+extern uchar *lwpoly_serialize(LWPOLY *poly);
 
 // same as above, writes to buf
-extern void lwpoly_serialize_buf(LWPOLY *poly, char *buf, size_t *size);
+extern void lwpoly_serialize_buf(LWPOLY *poly, uchar *buf, size_t *size);
 
 // find bounding box (standard one)  zmin=zmax=0 if 2d (might change to NaN)
 extern BOX3D *lwpoly_findbbox(LWPOLY *poly);
@@ -517,26 +521,26 @@ extern BOX3D *lwpoly_findbbox(LWPOLY *poly);
 
 extern size_t lwgeom_serialize_size(LWGEOM *geom);
 extern size_t lwcollection_serialize_size(LWCOLLECTION *coll);
-extern void lwgeom_serialize_buf(LWGEOM *geom, char *buf, size_t *size);
-extern char *lwgeom_serialize(LWGEOM *geom);
-extern void lwcollection_serialize_buf(LWCOLLECTION *mcoll, char *buf, size_t *size);
+extern void lwgeom_serialize_buf(LWGEOM *geom, uchar *buf, size_t *size);
+extern uchar *lwgeom_serialize(LWGEOM *geom);
+extern void lwcollection_serialize_buf(LWCOLLECTION *mcoll, uchar *buf, size_t *size);
 
 //-----------------------------------------------------
 
 // Deserialize an lwgeom serialized form.
 // The deserialized (recursive) structure will store
 // pointers to the serialized form (POINTARRAYs).
-LWGEOM *lwgeom_deserialize(char *serializedform);
+LWGEOM *lwgeom_deserialize(uchar *serializedform);
 
 // Release memory associated with LWGEOM.
 // POINTARRAYs are not released as they are usually
 // pointers to user-managed memory.
 void lwgeom_release(LWGEOM *lwgeom);
 
-LWMPOINT *lwmpoint_deserialize(char *serializedform);
-LWMLINE *lwmline_deserialize(char *serializedform);
-LWMPOLY *lwmpoly_deserialize(char *serializedform);
-LWCOLLECTION *lwcollection_deserialize(char *serializedform);
+LWMPOINT *lwmpoint_deserialize(uchar *serializedform);
+LWMLINE *lwmline_deserialize(uchar *serializedform);
+LWMPOLY *lwmpoly_deserialize(uchar *serializedform);
+LWCOLLECTION *lwcollection_deserialize(uchar *serializedform);
 LWGEOM *lwcollection_getsubgeom(LWCOLLECTION *, int);
 
 
@@ -564,10 +568,10 @@ LWGEOM *lwcollection_getsubgeom(LWCOLLECTION *, int);
 typedef struct
 {
        int   SRID;
-       const char  *serialized_form; // orginal structure
-       unsigned char  type;            // 8-bit type for the LWGEOM
+       const uchar *serialized_form; // orginal structure
+       uchar  type;            // 8-bit type for the LWGEOM
        int ngeometries;        // number of sub-geometries
-       char **sub_geoms;  // list of pointers (into serialized_form) of the sub-geoms
+       uchar **sub_geoms;  // list of pointers (into serialized_form) of the sub-geoms
 } LWGEOM_INSPECTED;
 
 extern int lwgeom_size_inspected(const LWGEOM_INSPECTED *inspected, int geom_number);
@@ -580,13 +584,13 @@ extern int lwgeom_size_inspected(const LWGEOM_INSPECTED *inspected, int geom_num
 typedef struct
 {
        int SRID;
-       unsigned char dims;
+       uchar dims;
        uint32 npoints;
-       char **points;
+       uchar **points;
        uint32 nlines;
-       char **lines;
+       uchar **lines;
        uint32 npolys;
-       char **polys;
+       uchar **polys;
 } LWGEOM_EXPLODED;
 
 void pfree_exploded(LWGEOM_EXPLODED *exploded);
@@ -599,7 +603,7 @@ LWGEOM_EXPLODED * lwexploded_sum(LWGEOM_EXPLODED *exp1, LWGEOM_EXPLODED *exp2);
  * This function recursively scan the given serialized geometry
  * and returns a list of _all_ subgeoms in it (deep-first)
  */
-extern LWGEOM_EXPLODED *lwgeom_explode(char *serialized);
+extern LWGEOM_EXPLODED *lwgeom_explode(uchar *serialized);
 
 /*
  * Return the length of the serialized form corresponding
@@ -610,38 +614,38 @@ extern size_t lwexploded_findlength(LWGEOM_EXPLODED *exp, int wantbbox);
 // Serialize an LWGEOM_EXPLODED object.
 // SRID and ndims will be taken from exploded structure.
 // wantbbox will determine result bbox.
-extern char *lwexploded_serialize(LWGEOM_EXPLODED *exploded, int wantbbox);
+extern uchar *lwexploded_serialize(LWGEOM_EXPLODED *exploded, int wantbbox);
 
 // Same as lwexploded_serialize but writing to pre-allocated space
-extern void lwexploded_serialize_buf(LWGEOM_EXPLODED *exploded, int wantbbox, char *buf, size_t *retsize);
+extern void lwexploded_serialize_buf(LWGEOM_EXPLODED *exploded, int wantbbox, uchar *buf, size_t *retsize);
 
 // note - for a simple type (ie. point), this will have sub_geom[0] = serialized_form.
 // for multi-geomtries sub_geom[0] will be a few bytes into the serialized form
 // This function just computes the length of each sub-object and pre-caches this info.
 // For a geometry collection of multi* geometries, you can inspect the sub-components
 // as well.
-extern LWGEOM_INSPECTED *lwgeom_inspect(const char *serialized_form);
+extern LWGEOM_INSPECTED *lwgeom_inspect(const uchar *serialized_form);
 
 
 // 1st geometry has geom_number = 0
 // if the actual sub-geometry isnt a POINT, null is returned (see _gettype()).
 // if there arent enough geometries, return null.
 // this is fine to call on a point (with geom_num=0), multipoint or geometrycollection
-extern LWPOINT *lwgeom_getpoint(char *serialized_form, int geom_number);
+extern LWPOINT *lwgeom_getpoint(uchar *serialized_form, int geom_number);
 extern LWPOINT *lwgeom_getpoint_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
 
 // 1st geometry has geom_number = 0
 // if the actual geometry isnt a LINE, null is returned (see _gettype()).
 // if there arent enough geometries, return null.
 // this is fine to call on a line, multiline or geometrycollection
-extern LWLINE *lwgeom_getline(char *serialized_form, int geom_number);
+extern LWLINE *lwgeom_getline(uchar *serialized_form, int geom_number);
 extern LWLINE *lwgeom_getline_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
 
 // 1st geometry has geom_number = 0
 // if the actual geometry isnt a POLYGON, null is returned (see _gettype()).
 // if there arent enough geometries, return null.
 // this is fine to call on a polygon, multipolygon or geometrycollection
-extern LWPOLY *lwgeom_getpoly(char *serialized_form, int geom_number);
+extern LWPOLY *lwgeom_getpoly(uchar *serialized_form, int geom_number);
 extern LWPOLY *lwgeom_getpoly_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
 
 // this gets the serialized form of a sub-geometry
@@ -655,8 +659,8 @@ extern LWPOLY *lwgeom_getpoly_inspected(LWGEOM_INSPECTED *inspected, int geom_nu
 //   ie. lwgeom_getpoint( lwgeom_getsubgeometry( serialized, 0), 1)
 //           --> POINT(1 1)
 // you can inspect the sub-geometry as well if you wish.
-extern char *lwgeom_getsubgeometry(const char *serialized_form, int geom_number);
-extern char *lwgeom_getsubgeometry_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
+extern uchar *lwgeom_getsubgeometry(const uchar *serialized_form, int geom_number);
+extern uchar *lwgeom_getsubgeometry_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
 
 
 // 1st geometry has geom_number = 0
@@ -666,13 +670,13 @@ extern char *lwgeom_getsubgeometry_inspected(LWGEOM_INSPECTED *inspected, int ge
 //   ie lwgeom_gettype( <'MULTIPOINT(0 0, 1 1)'>, 0)
 //                 --> point
 // gets the 8bit type of the geometry at location geom_number
-extern char lwgeom_getsubtype(char *serialized_form, int geom_number);
-extern char lwgeom_getsubtype_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
+extern uchar lwgeom_getsubtype(uchar *serialized_form, int geom_number);
+extern uchar lwgeom_getsubtype_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
 
 
 // how many sub-geometries are there?
 //  for point,line,polygon will return 1.
-extern int lwgeom_getnumgeometries(char *serialized_form);
+extern int lwgeom_getnumgeometries(uchar *serialized_form);
 extern int lwgeom_getnumgeometries_inspected(LWGEOM_INSPECTED *inspected);
 
 
@@ -682,22 +686,22 @@ extern int lwgeom_getnumgeometries_inspected(LWGEOM_INSPECTED *inspected);
 //  use SRID=-1 for unknown SRID  (will have 8bit type's S = 0)
 // all subgeometries must have the same SRID
 // if you want to construct an inspected, call this then inspect the result...
-extern char *lwgeom_serialized_construct(int SRID, int finalType, char hasz, char hasm, int nsubgeometries, char **serialized_subs);
+extern uchar *lwgeom_serialized_construct(int SRID, int finalType, char hasz, char hasm, int nsubgeometries, uchar **serialized_subs);
 
 
 // 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, size_t *size);
+extern uchar *lwgeom_constructempty(int SRID, char hasz, char hasm);
+extern void lwgeom_constructempty_buf(int SRID, char hasz, char hasm, uchar *buf, size_t *size);
 size_t lwgeom_empty_length(int SRID);
 
 // get the SRID from the LWGEOM
 // none present => -1
 extern int pglwgeom_getSRID(PG_LWGEOM *lwgeom);
-extern int lwgeom_getsrid(char *serialized);
+extern int lwgeom_getsrid(uchar *serialized);
 extern PG_LWGEOM *pglwgeom_setSRID(PG_LWGEOM *lwgeom, int32 newSRID);
 
 //get bounding box of LWGEOM (automatically calls the sub-geometries bbox generators)
-extern BOX3D *lw_geom_getBB(char *serialized_form);
+extern BOX3D *lw_geom_getBB(uchar *serialized_form);
 extern BOX3D *lw_geom_getBB_inspected(LWGEOM_INSPECTED *inspected);
 
 
@@ -722,16 +726,16 @@ extern BOX3D *combine_boxes(BOX3D *b1, BOX3D *b2);
 // otherwise we need to compute it.
 // WARNING! the EMPTY geom will result in a random BOX2D returned
 // OBSOLETED for this reason
-//extern BOX2DFLOAT4 getbox2d(char *serialized_form);
+//extern BOX2DFLOAT4 getbox2d(uchar *serialized_form);
 
 // Returns a pointer to the BBOX internal to the serialized form.
 // READ-ONLY!
 // Or NULL if serialized form does not have a BBOX
-extern BOX2DFLOAT4 *getbox2d_internal(char *serialized_form);
+extern BOX2DFLOAT4 *getbox2d_internal(uchar *serialized_form);
 
 // this function writes to 'box' and returns 0 if serialized_form
 // does not have a bounding box (empty geom)
-extern int getbox2d_p(char *serialized_form, BOX2DFLOAT4 *box);
+extern int getbox2d_p(uchar *serialized_form, BOX2DFLOAT4 *box);
 
 // Expand given box of 'd' units in all directions 
 void expand_box2d(BOX2DFLOAT4 *box, double d);
@@ -755,15 +759,15 @@ extern void pfree_POINTARRAY(POINTARRAY *pa);
 //***********************************************************
 // utility
 
-extern uint32 get_uint32(const char *loc);
-extern int32 get_int32(const char *loc);
+extern uint32 get_uint32(const uchar *loc);
+extern int32 get_int32(const uchar *loc);
 extern void printPA(POINTARRAY *pa);
 extern void printLWPOINT(LWPOINT *point);
 extern void printLWLINE(LWLINE *line);
 extern void printLWPOLY(LWPOLY *poly);
-extern void printBYTES(unsigned char *a, int n);
-extern void printMULTI(char *serialized);
-extern void printType(unsigned char str);
+extern void printBYTES(uchar *a, int n);
+extern void printMULTI(uchar *serialized);
+extern void printType(uchar str);
 
 
 //------------------------------------------------------------
@@ -908,10 +912,10 @@ extern double lwgeom_polygon_perimeter(LWPOLY *poly);
 extern double lwgeom_polygon_perimeter2d(LWPOLY *poly);
 extern double lwgeom_pointarray_length2d(POINTARRAY *pts);
 extern double lwgeom_pointarray_length(POINTARRAY *pts);
-extern void lwgeom_force2d_recursive(char *serialized, char *optr, size_t *retsize);
-extern void lwgeom_force3dz_recursive(char *serialized, char *optr, size_t *retsize);
-extern void lwgeom_force3dm_recursive(unsigned char *serialized, char *optr, size_t *retsize);
-extern void lwgeom_force4d_recursive(char *serialized, char *optr, size_t *retsize);
+extern void lwgeom_force2d_recursive(uchar *serialized, uchar *optr, size_t *retsize);
+extern void lwgeom_force3dz_recursive(uchar *serialized, uchar *optr, size_t *retsize);
+extern void lwgeom_force3dm_recursive(uchar *serialized, uchar *optr, size_t *retsize);
+extern void lwgeom_force4d_recursive(uchar *serialized, uchar *optr, size_t *retsize);
 extern double distance2d_pt_pt(POINT2D *p1, POINT2D *p2);
 extern double distance2d_pt_seg(POINT2D *p, POINT2D *A, POINT2D *B);
 extern double distance2d_seg_seg(POINT2D *A, POINT2D *B, POINT2D *C, POINT2D *D);
@@ -926,11 +930,11 @@ extern double distance2d_line_line(LWLINE *line1, LWLINE *line2);
 extern double distance2d_point_poly(LWPOINT *point, LWPOLY *poly);
 extern double distance2d_poly_poly(LWPOLY *poly1, LWPOLY *poly2);
 extern double distance2d_line_poly(LWLINE *line, LWPOLY *poly);
-extern double lwgeom_mindistance2d_recursive(char *lw1, char *lw2);
-extern void lwgeom_translate_recursive(char *serialized, double xoff, double yoff, double zoff);
+extern double lwgeom_mindistance2d_recursive(uchar *lw1, uchar *lw2);
+extern void lwgeom_translate_recursive(uchar *serialized, double xoff, double yoff, double zoff);
 extern void lwgeom_translate_ptarray(POINTARRAY *pa, double xoff, double yoff, double zoff);
 extern int lwgeom_pt_inside_circle(POINT2D *p, double cx, double cy, double rad);
-extern int32 lwgeom_npoints(char *serialized);
+extern int32 lwgeom_npoints(uchar *serialized);
 extern char ptarray_isccw(const POINTARRAY *pa);
 extern void lwgeom_reverse(LWGEOM *lwgeom);
 extern void lwline_reverse(LWLINE *line);
@@ -1011,7 +1015,7 @@ extern LWLINE *lwline_addpoint(LWLINE *line, LWPOINT *point, unsigned int where)
 extern LWPOLY *lwpoly_from_lwlines(const LWLINE *shell, unsigned int nholes, const LWLINE **holes);
 
 // Return a char string with ASCII versionf of type flags
-extern const char *lwgeom_typeflags(unsigned char type);
+extern const uchar *lwgeom_typeflags(uchar type);
 
 // Construct an empty pointarray
 extern POINTARRAY *ptarray_construct(char hasz, char hasm, unsigned int npoints);
@@ -1019,10 +1023,10 @@ extern POINTARRAY *ptarray_construct2d(uint32 npoints, const POINT2D *pts);
 extern POINTARRAY *ptarray_construct3dz(uint32 npoints, const POINT3DZ *pts);
 extern POINTARRAY *ptarray_construct3dm(uint32 npoints, const POINT3DM *pts);
 extern POINTARRAY *ptarray_construct4d(uint32 npoints, const POINT4D *pts);
-extern POINTARRAY *ptarray_addPoint(POINTARRAY *pa, char *p, size_t pdims, unsigned int where);
+extern POINTARRAY *ptarray_addPoint(POINTARRAY *pa, uchar *p, size_t pdims, unsigned int where);
 extern int ptarray_isclosed2d(const POINTARRAY *pa);
 
-extern int32 lwgeom_nrings_recursive(char *serialized);
+extern int32 lwgeom_nrings_recursive(uchar *serialized);
 extern void dump_lwexploded(LWGEOM_EXPLODED *exploded);
 extern void ptarray_reverse(POINTARRAY *pa);
 
@@ -1034,9 +1038,9 @@ extern LWLINE *lwline_segmentize2d(LWLINE *line, double dist);
 extern LWPOLY *lwpoly_segmentize2d(LWPOLY *line, double dist);
 extern LWCOLLECTION *lwcollection_segmentize2d(LWCOLLECTION *coll, double dist);
 
-extern unsigned char   parse_hex(char *str);
-extern void deparse_hex(unsigned char str, unsigned char *result);
-extern char *parse_lwgeom_wkt(char *wkt_input);
+extern uchar parse_hex(char *str);
+extern void deparse_hex(uchar str, uchar *result);
+extern uchar *parse_lwgeom_wkt(char *wkt_input);
 extern char *lwgeom_to_wkt(LWGEOM *lwgeom);
 extern char *lwgeom_to_hexwkb(LWGEOM *lwgeom, unsigned int byteorder);
 
index 8f976677c055b6d4311f8ea859d49d574e18298b..d8ca9c5e091352bd5195388b0d19665b4ad4cf19 100644 (file)
@@ -64,7 +64,7 @@ lwcollection_construct_empty(int SRID, char hasz, char hasm)
 
 
 LWCOLLECTION *
-lwcollection_deserialize(char *srl)
+lwcollection_deserialize(uchar *srl)
 {
        LWCOLLECTION *result;
        LWGEOM_INSPECTED *insp;
@@ -139,12 +139,12 @@ lwcollection_serialize_size(LWCOLLECTION *col)
 // the given buffer, and returning number of bytes written into
 // the given int pointer.
 void
-lwcollection_serialize_buf(LWCOLLECTION *coll, char *buf, size_t *retsize)
+lwcollection_serialize_buf(LWCOLLECTION *coll, uchar *buf, size_t *retsize)
 {
        size_t size=1; // type 
        size_t subsize=0;
        char hasSRID;
-       char *loc;
+       uchar *loc;
        int i;
 
 #ifdef PGIS_DEBUG_CALLS
@@ -154,7 +154,7 @@ lwcollection_serialize_buf(LWCOLLECTION *coll, char *buf, size_t *retsize)
 
        hasSRID = (coll->SRID != -1);
 
-       buf[0] = (unsigned char) lwgeom_makeType_full(
+       buf[0] = lwgeom_makeType_full(
                TYPE_HASZ(coll->type), TYPE_HASM(coll->type),
                hasSRID, TYPE_GETTYPE(coll->type), coll->bbox ? 1 : 0);
        loc = buf+1;
@@ -295,7 +295,7 @@ char
 lwcollection_same(const LWCOLLECTION *c1, const LWCOLLECTION *c2)
 {
        unsigned int i, j;
-       char *hit;
+       unsigned int *hit;
 
 #if PGIS_DEBUG_CALLS
        lwnotice("lwcollection_same called");
@@ -304,8 +304,8 @@ lwcollection_same(const LWCOLLECTION *c1, const LWCOLLECTION *c2)
        if ( TYPE_GETTYPE(c1->type) != TYPE_GETTYPE(c2->type) ) return 0;
        if ( c1->ngeoms != c2->ngeoms ) return 0;
 
-       hit = (char *)lwalloc(sizeof(char)*c1->ngeoms);
-       memset(hit, 0, sizeof(char)*c1->ngeoms);
+       hit = lwalloc(sizeof(unsigned int)*c1->ngeoms);
+       memset(hit, 0, sizeof(unsigned int)*c1->ngeoms);
 
        for (i=0; i<c1->ngeoms; i++)
        {
index 58fcbc9408bcaaeec8439f41ec8d5223a0437dd5..1c77cace36fbc54af8411d98ab7349b606af4979 100644 (file)
@@ -9,7 +9,7 @@
 //#define PGIS_DEBUG_CALLS 1
 
 LWGEOM *
-lwgeom_deserialize(char *srl)
+lwgeom_deserialize(uchar *srl)
 {
        int type = lwgeom_getType(srl[0]);
 
@@ -67,7 +67,7 @@ lwgeom_serialize_size(LWGEOM *lwgeom)
 }
 
 void
-lwgeom_serialize_buf(LWGEOM *lwgeom, char *buf, size_t *retsize)
+lwgeom_serialize_buf(LWGEOM *lwgeom, uchar *buf, size_t *retsize)
 {
        int type = TYPE_GETTYPE(lwgeom->type);
 
@@ -100,12 +100,12 @@ lwgeom_serialize_buf(LWGEOM *lwgeom, char *buf, size_t *retsize)
        return;
 }
 
-char *
+uchar *
 lwgeom_serialize(LWGEOM *lwgeom)
 {
        size_t size = lwgeom_serialize_size(lwgeom);
        size_t retsize;
-       char *serialized = lwalloc(size);
+       uchar *serialized = lwalloc(size);
 
        lwgeom_serialize_buf(lwgeom, serialized, &retsize);
 
@@ -362,7 +362,7 @@ lwgeom_add(const LWGEOM *to, uint32 where, const LWGEOM *what)
 char *
 lwgeom_to_wkt(LWGEOM *lwgeom)
 {
-       char *serialized = lwgeom_serialize(lwgeom);
+       uchar *serialized = lwgeom_serialize(lwgeom);
        char *ret;
        if ( ! serialized ) {
                lwerror("Error serializing geom %p", lwgeom);
@@ -378,7 +378,7 @@ lwgeom_to_wkt(LWGEOM *lwgeom)
 char *
 lwgeom_to_hexwkb(LWGEOM *lwgeom, unsigned int byteorder)
 {
-       char *serialized = lwgeom_serialize(lwgeom);
+       uchar *serialized = lwgeom_serialize(lwgeom);
        char *hexwkb = unparse_WKB(serialized, lwalloc, lwfree, byteorder,NULL,1);
        lwfree(serialized);
        return hexwkb;
index 9bab778546c0a11405487c2c6117f939180b1575..6a0f2fef403884cef183b4c9a08ce964f18daa1c 100644 (file)
 // This is an implementation of the functions defined in lwgeom.h
 
 //forward decs
-extern BOX3D *lw_geom_getBB_simple(char *serialized_form);
+extern BOX3D *lw_geom_getBB_simple(uchar *serialized_form);
 #ifdef PGIS_DEBUG_EXPLODED
-void checkexplodedsize(char *srl, LWGEOM_EXPLODED *exploded, int alloced, char wantbbox);
+void checkexplodedsize(uchar *srl, LWGEOM_EXPLODED *exploded, int alloced, char wantbbox);
 #endif
-extern char *parse_lwg(const char* geometry, lwallocator allocfunc, lwreporter errfunc);
+extern uchar *parse_lwg(const char* geometry, lwallocator allocfunc, lwreporter errfunc);
 
 //*********************************************************************
 // BOX routines
@@ -312,7 +312,7 @@ BOX3D *combine_boxes(BOX3D *b1, BOX3D *b2)
 // returns a pointer to internal storage, or NULL
 // if the serialized form does not have a BBOX.
 BOX2DFLOAT4 *
-getbox2d_internal(char *srl)
+getbox2d_internal(uchar *srl)
 {
        if (TYPE_HASBBOX(srl[0])) return (BOX2DFLOAT4 *)(srl+1);
        else return NULL;
@@ -320,10 +320,10 @@ getbox2d_internal(char *srl)
 
 // same as getbox2d, but modifies box instead of returning result on the stack
 int
-getbox2d_p(char *serialized_form, BOX2DFLOAT4 *box)
+getbox2d_p(uchar *serialized_form, BOX2DFLOAT4 *box)
 {
-       char type = serialized_form[0];
-       char *loc;
+       uchar type = serialized_form[0];
+       uchar *loc;
        BOX3D *box3d;
 
 #ifdef PGIS_DEBUG
@@ -592,7 +592,7 @@ getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
 // You'll need to cast it to appropriate dimensioned point.
 // Note that if you cast to a higher dimensional point you'll
 // possibly corrupt the POINTARRAY.
-char *
+uchar *
 getPoint(const POINTARRAY *pa, int n)
 {
        int size;
@@ -609,7 +609,6 @@ getPoint(const POINTARRAY *pa, int n)
 
        size = pointArray_ptsize(pa);
 
-       // this does x,y
        return &(pa->serialized_pointlist[size*n]);
 }
 
@@ -620,7 +619,8 @@ getPoint(const POINTARRAY *pa, int n)
 // NOTE: ndims is descriptive - it describes what type of data 'points'
 //       points to.  No data conversion is done.
 POINTARRAY *
-pointArray_construct(char *points, char hasz, char hasm, uint32 npoints)
+pointArray_construct(uchar *points, char hasz, char hasm,
+       uint32 npoints)
 {
        POINTARRAY  *pa;
        pa = (POINTARRAY*)lwalloc(sizeof(POINTARRAY));
@@ -715,6 +715,7 @@ pointArray_bbox(const POINTARRAY *pa)
 int
 pointArray_ptsize(const POINTARRAY *pa)
 {
+       //fprintf(stderr, "pointArray_ptsize: TYPE_NDIMS(pa->dims)=%x\n", TYPE_NDIMS(pa->dims));
        return sizeof(double)*TYPE_NDIMS(pa->dims);
 }
 
@@ -725,40 +726,41 @@ pointArray_ptsize(const POINTARRAY *pa)
 
 // returns true if this type says it has an SRID (S bit set)
 char
-lwgeom_hasSRID(unsigned char type)
+lwgeom_hasSRID(uchar type)
 {
        return TYPE_HASSRID(type);
 }
 
 // returns either 2,3, or 4 -- 2=2D, 3=3D, 4=4D
 int
-lwgeom_ndims(unsigned char type)
+lwgeom_ndims(uchar type)
 {
        return TYPE_NDIMS(type);
 }
 
 // has M ?
-int lwgeom_hasM(unsigned char type)
+int lwgeom_hasM(uchar type)
 {
        return  ( (type & 0x10) >>4);
 }
 
 // has Z ?
-int lwgeom_hasZ(unsigned char type)
+int lwgeom_hasZ(uchar type)
 {
        return  ( (type & 0x20) >>5);
 }
 
 
 // get base type (ie. POLYGONTYPE)
-int  lwgeom_getType(unsigned char type)
+int
+lwgeom_getType(uchar type)
 {
        return (type & 0x0F);
 }
 
 
 //construct a type (hasBOX=false)
-unsigned char
+uchar
 lwgeom_makeType(char hasz, char hasm, char hasSRID, int type)
 {
        return lwgeom_makeType_full(hasz, hasm, hasSRID, type, 0);
@@ -768,10 +770,10 @@ lwgeom_makeType(char hasz, char hasm, char hasSRID, int type)
  * Construct a type
  * TODO: needs to be expanded to accept explicit MZ type
  */
-unsigned char
+uchar
 lwgeom_makeType_full(char hasz, char hasm, char hasSRID, int type, char hasBBOX)
 {
-       unsigned char result = (char)type;
+       uchar result = (char)type;
 
        TYPE_SETZM(result, hasz, hasm);
        TYPE_SETHASSRID(result, hasSRID);
@@ -782,7 +784,7 @@ lwgeom_makeType_full(char hasz, char hasm, char hasSRID, int type, char hasBBOX)
 
 //returns true if there's a bbox in this LWGEOM (B bit set)
 char
-lwgeom_hasBBOX(unsigned char type)
+lwgeom_hasBBOX(uchar type)
 {
        return TYPE_HASBBOX(type);
 }
@@ -792,7 +794,7 @@ lwgeom_hasBBOX(unsigned char type)
 
 // handle missaligned unsigned int32 data
 uint32
-get_uint32(const char *loc)
+get_uint32(const uchar *loc)
 {
        uint32 result;
 
@@ -802,7 +804,7 @@ get_uint32(const char *loc)
 
 // handle missaligned signed int32 data
 int32
-get_int32(const char *loc)
+get_int32(const uchar *loc)
 {
        int32 result;
 
@@ -824,13 +826,13 @@ get_int32(const char *loc)
 // For a geometry collection of multi* geometries, you can inspect the sub-components
 // as well.
 LWGEOM_INSPECTED *
-lwgeom_inspect(const char *serialized_form)
+lwgeom_inspect(const uchar *serialized_form)
 {
        LWGEOM_INSPECTED *result = lwalloc(sizeof(LWGEOM_INSPECTED));
-       unsigned char typefl = (unsigned char)serialized_form[0];
-       unsigned char type;
-       char **sub_geoms;
-       const char *loc;
+       uchar typefl = (uchar)serialized_form[0];
+       uchar type;
+       uchar **sub_geoms;
+       const uchar *loc;
        int     t;
 
 #ifdef PGIS_DEBUG
@@ -841,7 +843,7 @@ lwgeom_inspect(const char *serialized_form)
                return NULL;
 
        result->serialized_form = serialized_form; 
-       result->type = (unsigned char) serialized_form[0];
+       result->type = (uchar) serialized_form[0];
        result->SRID = -1; // assume
 
        type = lwgeom_getType(typefl);
@@ -863,9 +865,9 @@ lwgeom_inspect(const char *serialized_form)
        {
                //simple geometry (point/line/polygon)-- not multi!
                result->ngeometries = 1;
-               sub_geoms = (char**) lwalloc(sizeof(char*));
-               sub_geoms[0] = (char *)serialized_form;
-               result->sub_geoms = (char **)sub_geoms;
+               sub_geoms = (uchar**) lwalloc(sizeof(char*));
+               sub_geoms[0] = (uchar *)serialized_form;
+               result->sub_geoms = (uchar **)sub_geoms;
                return result;
        }
 
@@ -880,9 +882,9 @@ lwgeom_inspect(const char *serialized_form)
 
        if ( ! result->ngeometries ) return result;
 
-       sub_geoms = (char**) lwalloc(sizeof(char*) * result->ngeometries );
+       sub_geoms = lwalloc(sizeof(uchar*) * result->ngeometries );
        result->sub_geoms = sub_geoms;
-       sub_geoms[0] = (char *)loc;
+       sub_geoms[0] = (uchar *)loc;
 #ifdef PGIS_DEBUG
        lwnotice("subgeom[0] @ %p (+%d)", sub_geoms[0], sub_geoms[0]-serialized_form);
 #endif
@@ -904,11 +906,13 @@ lwgeom_inspect(const char *serialized_form)
 // 1st geometry has geom_number = 0
 // if the actual sub-geometry isnt a POINT, null is returned (see _gettype()).
 // if there arent enough geometries, return null.
-// this is fine to call on a point (with geom_num=0), multipoint or geometrycollection
-LWPOINT *lwgeom_getpoint(char *serialized_form, int geom_number)
+// this is fine to call on a point (with geom_num=0),
+// multipoint or geometrycollection
+LWPOINT *
+lwgeom_getpoint(uchar *serialized_form, int geom_number)
 {
-       char type = lwgeom_getType((unsigned char)serialized_form[0]);
-       char *sub_geom;
+       int type = lwgeom_getType((uchar)serialized_form[0]);
+       uchar *sub_geom;
 
        if ((type == POINTTYPE)  && (geom_number == 0))
        {
@@ -923,7 +927,7 @@ LWPOINT *lwgeom_getpoint(char *serialized_form, int geom_number)
        if (sub_geom == NULL)
                return NULL;
 
-       type = lwgeom_getType( (unsigned char) sub_geom[0]);
+       type = lwgeom_getType(sub_geom[0]);
        if (type != POINTTYPE)
                return NULL;
 
@@ -937,13 +941,13 @@ LWPOINT *lwgeom_getpoint(char *serialized_form, int geom_number)
 LWPOINT *lwgeom_getpoint_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
 {
        char *sub_geom;
-       unsigned char type;
+       uchar type;
 
        sub_geom = lwgeom_getsubgeometry_inspected(inspected, geom_number);
 
        if (sub_geom == NULL) return NULL;
 
-       type = lwgeom_getType( (unsigned char) sub_geom[0]);
+       type = lwgeom_getType( (uchar) sub_geom[0]);
        if (type != POINTTYPE) return NULL;
 
        return lwpoint_deserialize(sub_geom);
@@ -954,10 +958,11 @@ LWPOINT *lwgeom_getpoint_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
 // if the actual geometry isnt a LINE, null is returned (see _gettype()).
 // if there arent enough geometries, return null.
 // this is fine to call on a line, multiline or geometrycollection
-LWLINE *lwgeom_getline(char *serialized_form, int geom_number)
+LWLINE *
+lwgeom_getline(uchar *serialized_form, int geom_number)
 {
-       unsigned char type = lwgeom_getType( (unsigned char) serialized_form[0]);
-       char *sub_geom;
+       uchar type = lwgeom_getType( (uchar) serialized_form[0]);
+       uchar *sub_geom;
 
        if ((type == LINETYPE)  && (geom_number == 0))
        {
@@ -971,7 +976,7 @@ LWLINE *lwgeom_getline(char *serialized_form, int geom_number)
        sub_geom = lwgeom_getsubgeometry(serialized_form, geom_number);
        if (sub_geom == NULL) return NULL;
 
-       type = lwgeom_getType((unsigned char) sub_geom[0]);
+       type = lwgeom_getType((uchar) sub_geom[0]);
        if (type != LINETYPE) return NULL;
 
        return lwline_deserialize(sub_geom);
@@ -983,14 +988,14 @@ LWLINE *lwgeom_getline(char *serialized_form, int geom_number)
 // this is fine to call on a line, multiline or geometrycollection
 LWLINE *lwgeom_getline_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
 {
-       char *sub_geom;
-       unsigned char type;
+       uchar *sub_geom;
+       uchar type;
 
        sub_geom = lwgeom_getsubgeometry_inspected(inspected, geom_number);
 
        if (sub_geom == NULL) return NULL;
 
-       type = lwgeom_getType((unsigned char) sub_geom[0]);
+       type = lwgeom_getType((uchar) sub_geom[0]);
        if (type != LINETYPE) return NULL;
 
        return lwline_deserialize(sub_geom);
@@ -1000,9 +1005,10 @@ LWLINE *lwgeom_getline_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
 // if the actual geometry isnt a POLYGON, null is returned (see _gettype()).
 // if there arent enough geometries, return null.
 // this is fine to call on a polygon, multipolygon or geometrycollection
-LWPOLY *lwgeom_getpoly(char *serialized_form, int geom_number)
+LWPOLY *
+lwgeom_getpoly(uchar *serialized_form, int geom_number)
 {
-       unsigned char type = lwgeom_getType((unsigned char)serialized_form[0]);
+       uchar type = lwgeom_getType((uchar)serialized_form[0]);
        char *sub_geom;
 
        if ((type == POLYGONTYPE)  && (geom_number == 0))
@@ -1017,7 +1023,7 @@ LWPOLY *lwgeom_getpoly(char *serialized_form, int geom_number)
        sub_geom = lwgeom_getsubgeometry(serialized_form, geom_number);
        if (sub_geom == NULL) return NULL;
 
-       type = lwgeom_getType((unsigned char) sub_geom[0]);
+       type = lwgeom_getType((uchar) sub_geom[0]);
        if (type != POLYGONTYPE) return NULL;
 
        return lwpoly_deserialize(sub_geom);
@@ -1030,13 +1036,13 @@ LWPOLY *lwgeom_getpoly(char *serialized_form, int geom_number)
 LWPOLY *lwgeom_getpoly_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
 {
        char *sub_geom;
-       unsigned char type;
+       uchar type;
 
        sub_geom = lwgeom_getsubgeometry_inspected(inspected, geom_number);
 
        if (sub_geom == NULL) return NULL;
 
-       type = lwgeom_getType((unsigned char) sub_geom[0]);
+       type = lwgeom_getType((uchar) sub_geom[0]);
        if (type != POLYGONTYPE) return NULL;
 
        return lwpoly_deserialize(sub_geom);
@@ -1053,8 +1059,8 @@ LWPOLY *lwgeom_getpoly_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
 //   ie. lwgeom_getpoint( lwgeom_getsubgeometry( serialized, 0), 1)
 //           --> POINT(1 1)
 // you can inspect the sub-geometry as well if you wish.
-char *
-lwgeom_getsubgeometry(const char *serialized_form, int geom_number)
+uchar *
+lwgeom_getsubgeometry(const uchar *serialized_form, int geom_number)
 {
        //major cheat!!
        char * result;
@@ -1065,7 +1071,7 @@ lwgeom_getsubgeometry(const char *serialized_form, int geom_number)
        return result;
 }
 
-char *
+uchar *
 lwgeom_getsubgeometry_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
 {
        if ((geom_number <0) || (geom_number >= inspected->ngeometries) )
@@ -1085,8 +1091,8 @@ lwgeom_getsubgeometry_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
 //   ie lwgeom_gettype( <'MULTIPOINT(0 0, 1 1)'>, 0)
 //                 --> point
 // gets the 8bit type of the geometry at location geom_number
-char
-lwgeom_getsubtype(char *serialized_form, int geom_number)
+uchar
+lwgeom_getsubtype(uchar *serialized_form, int geom_number)
 {
        //major cheat!!
        char  result;
@@ -1097,7 +1103,8 @@ lwgeom_getsubtype(char *serialized_form, int geom_number)
        return result;
 }
 
-char lwgeom_getsubtype_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
+uchar
+lwgeom_getsubtype_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
 {
        if ((geom_number <0) || (geom_number >= inspected->ngeometries) )
                return 99;
@@ -1108,10 +1115,11 @@ char lwgeom_getsubtype_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
 
 // how many sub-geometries are there?
 //  for point,line,polygon will return 1.
-int lwgeom_getnumgeometries(char *serialized_form)
+int
+lwgeom_getnumgeometries(uchar *serialized_form)
 {
-       unsigned char type = lwgeom_getType((unsigned char)serialized_form[0]);
-       char *loc;
+       uchar type = lwgeom_getType((uchar)serialized_form[0]);
+       uchar *loc;
 
        if ( (type==POINTTYPE) || (type==LINETYPE) || (type==POLYGONTYPE) )
        {
@@ -1120,12 +1128,12 @@ int lwgeom_getnumgeometries(char *serialized_form)
 
        loc = serialized_form+1;
 
-       if (lwgeom_hasBBOX((unsigned char) serialized_form[0]))
+       if (lwgeom_hasBBOX((uchar) serialized_form[0]))
        {
                loc += sizeof(BOX2DFLOAT4);
        }
 
-       if (lwgeom_hasSRID((unsigned char) serialized_form[0]) )
+       if (lwgeom_hasSRID((uchar) serialized_form[0]) )
        {
                loc += 4;
        }
@@ -1146,16 +1154,16 @@ int lwgeom_getnumgeometries_inspected(LWGEOM_INSPECTED *inspected)
 //  use SRID=-1 for unknown SRID  (will have 8bit type's S = 0)
 // all subgeometries must have the same SRID
 // if you want to construct an inspected, call this then inspect the result...
-char *
-lwgeom_serialized_construct(int SRID, int finalType, char hasz, char hasm, int nsubgeometries, char **serialized_subs)
+uchar *
+lwgeom_serialized_construct(int SRID, int finalType, char hasz, char hasm, int nsubgeometries, uchar **serialized_subs)
 {
        uint32 *lengths;
        int t;
        int total_length = 0;
        char type = -1;
        char this_type = -1;
-       char *result;
-       char *loc;
+       uchar *result;
+       uchar *loc;
 
        if (nsubgeometries == 0)
                return lwgeom_constructempty(SRID, hasz, hasm);
@@ -1166,7 +1174,7 @@ lwgeom_serialized_construct(int SRID, int finalType, char hasz, char hasm, int n
        {
                lengths[t] = lwgeom_size_subgeom(serialized_subs[t],-1);
                total_length += lengths[t];
-               this_type = lwgeom_getType((unsigned char) (serialized_subs[t][0]));
+               this_type = lwgeom_getType((uchar) (serialized_subs[t][0]));
                if (type == -1)
                {
                        type = this_type;
@@ -1220,7 +1228,7 @@ lwgeom_serialized_construct(int SRID, int finalType, char hasz, char hasm, int n
        total_length +=4 ;   // nsubgeometries
 
        result = lwalloc(total_length);
-       result[0] = (unsigned char) lwgeom_makeType(hasz, hasm, SRID != -1,  type);
+       result[0] = (uchar) lwgeom_makeType(hasz, hasm, SRID != -1,  type);
        if (SRID != -1)
        {
                memcpy(&result[1],&SRID,4);
@@ -1245,13 +1253,13 @@ lwgeom_serialized_construct(int SRID, int finalType, char hasz, char hasm, int n
 
 // construct the empty geometry (GEOMETRYCOLLECTION(EMPTY))
 //returns serialized form
-char *
+uchar *
 lwgeom_constructempty(int SRID, char hasz, char hasm)
 {
        int size = 0;
-       char *result;
+       uchar *result;
        int ngeoms = 0;
-       char *loc;
+       uchar *loc;
 
        if (SRID != -1)
                size +=4;
@@ -1285,11 +1293,11 @@ lwgeom_empty_length(int SRID)
 // writing it into the provided buffer.
 void
 lwgeom_constructempty_buf(int SRID, char hasz, char hasm,
-       char *buf, size_t *retsize)
+       uchar *buf, size_t *retsize)
 {
        int ngeoms = 0;
 
-       buf[0] =(unsigned char) lwgeom_makeType( hasz, hasm, SRID != -1,  COLLECTIONTYPE);
+       buf[0] =(uchar) lwgeom_makeType( hasz, hasm, SRID != -1,  COLLECTIONTYPE);
        if (SRID != -1)
        {
                memcpy(&buf[1],&SRID,4);
@@ -1314,11 +1322,11 @@ lwgeom_constructempty_buf(int SRID, char hasz, char hasm,
 
 // take a geometry, and find its length
 size_t
-lwgeom_size(const char *serialized_form)
+lwgeom_size(const uchar *serialized_form)
 {
-       unsigned char type = lwgeom_getType((unsigned char) serialized_form[0]);
+       uchar type = lwgeom_getType((uchar) serialized_form[0]);
        int t;
-       const char *loc;
+       const uchar *loc;
        uint32 ngeoms;
        int sub_size;
        int result = 1; //"type"
@@ -1364,7 +1372,7 @@ lwgeom_size(const char *serialized_form)
 
        loc = serialized_form+1;
 
-       if (lwgeom_hasBBOX((unsigned char) serialized_form[0]))
+       if (lwgeom_hasBBOX((uchar) serialized_form[0]))
        {
 #ifdef PGIS_DEBUG
                lwnotice("lwgeom_size: has bbox");
@@ -1374,7 +1382,7 @@ lwgeom_size(const char *serialized_form)
                result +=sizeof(BOX2DFLOAT4);
        }
 
-       if (lwgeom_hasSRID( (unsigned char) serialized_form[0]) )
+       if (lwgeom_hasSRID( (uchar) serialized_form[0]) )
        {
 #ifdef PGIS_DEBUG
                lwnotice("lwgeom_size: has srid");
@@ -1409,7 +1417,7 @@ lwgeom_size(const char *serialized_form)
 }
 
 size_t
-lwgeom_size_subgeom(const char *serialized_form, int geom_number)
+lwgeom_size_subgeom(const uchar *serialized_form, int geom_number)
 {
        if (geom_number == -1)
        {
@@ -1430,7 +1438,7 @@ lwgeom_size_inspected(const LWGEOM_INSPECTED *inspected, int geom_number)
 //get bounding box of LWGEOM (automatically calls the sub-geometries bbox generators)
 //dont forget to lwfree() result
 BOX3D *
-lw_geom_getBB(char *serialized_form)
+lw_geom_getBB(uchar *serialized_form)
 {
          LWGEOM_INSPECTED *inspected = lwgeom_inspect(serialized_form);
 
@@ -1445,9 +1453,9 @@ lw_geom_getBB(char *serialized_form)
 // the given location, the function returns 0 is the geometry
 // does not have a bounding box (EMPTY GEOM)
 int
-compute_serialized_bbox_p(char *serialized_form, BOX2DFLOAT4 *out)
+compute_serialized_bbox_p(uchar *srl, BOX2DFLOAT4 *out)
 {
-         LWGEOM_INSPECTED *inspected = lwgeom_inspect(serialized_form);
+         LWGEOM_INSPECTED *inspected = lwgeom_inspect(srl);
 
          BOX3D *result = lw_geom_getBB_inspected(inspected);
          if ( ! result ) return 0;
@@ -1461,11 +1469,11 @@ compute_serialized_bbox_p(char *serialized_form, BOX2DFLOAT4 *out)
 }
 
 //dont forget to lwfree() result
-BOX3D *lw_geom_getBB_simple(char *serialized_form)
+BOX3D *lw_geom_getBB_simple(uchar *serialized_form)
 {
-       int type = lwgeom_getType((unsigned char) serialized_form[0]);
+       int type = lwgeom_getType((uchar) serialized_form[0]);
        int t;
-       char *loc;
+       uchar *loc;
        uint32 ngeoms;
        BOX3D *result;
        BOX3D *b1,*b2;
@@ -1490,7 +1498,7 @@ lwnotice("lw_geom_getBB_simple: bbox found");
        /*
                result = lwalloc(sizeof(BOX3D));
                memcpy(result, serialized_form+1, sizeof(BOX2DFLOAT4));
-               memcpy(( (char *)result)+24, serialized_form+1, sizeof(BOX2DFLOAT4));
+               memcpy(((uchar *)result)+24, serialized_form+1, sizeof(BOX2DFLOAT4));
                return result;
        */
        }
@@ -1520,12 +1528,12 @@ lwnotice("lw_geom_getBB_simple: bbox found");
 
        loc = serialized_form+1;
 
-       if (lwgeom_hasBBOX((unsigned char) serialized_form[0]))
+       if (lwgeom_hasBBOX((uchar) serialized_form[0]))
        {
                loc += sizeof(BOX2DFLOAT4);
        }
 
-       if (lwgeom_hasSRID((unsigned char) serialized_form[0]) )
+       if (lwgeom_hasSRID((uchar) serialized_form[0]) )
        {
                loc +=4;
        }
@@ -1628,7 +1636,7 @@ void printPA(POINTARRAY *pa)
 {
        int t;
        POINT4D *pt;
-       char *mflag;
+       uchar *mflag;
 
        if ( TYPE_HASM(pa->dims) ) mflag = "M";
        else mflag = "";
@@ -1658,7 +1666,7 @@ void printPA(POINTARRAY *pa)
        lwnotice("      }");
 }
 
-void printBYTES(unsigned char *a, int n)
+void printBYTES(uchar *a, int n)
 {
        int t;
        char buff[3];
@@ -1676,7 +1684,7 @@ void printBYTES(unsigned char *a, int n)
 
 
 void
-printMULTI(char *serialized)
+printMULTI(uchar *serialized)
 {
        LWGEOM_INSPECTED *inspected = lwgeom_inspect(serialized);
        LWLINE  *line;
@@ -1684,7 +1692,7 @@ printMULTI(char *serialized)
        LWPOLY  *poly;
        int t;
 
-       lwnotice("MULTI* geometry (type = %i), with %i sub-geoms",lwgeom_getType((unsigned char)serialized[0]), inspected->ngeometries);
+       lwnotice("MULTI* geometry (type = %i), with %i sub-geoms",lwgeom_getType((uchar)serialized[0]), inspected->ngeometries);
 
        for (t=0;t<inspected->ngeometries;t++)
        {
@@ -1713,17 +1721,18 @@ printMULTI(char *serialized)
        pfree_inspected(inspected);
 }
 
-void printType(unsigned char type)
+void printType(uchar type)
 {
        lwnotice("type 0x%x ==> hasBBOX=%i, hasSRID=%i, ndims=%i, type=%i",(unsigned int) type, lwgeom_hasBBOX(type), lwgeom_hasSRID(type),lwgeom_ndims(type), lwgeom_getType(type));
 }
 
 // get the SRID from the LWGEOM
 // none present => -1
-int lwgeom_getsrid(char *serialized)
+int
+lwgeom_getsrid(uchar *serialized)
 {
-       unsigned char type = serialized[0];
-       char *loc = serialized+1;
+       uchar type = serialized[0];
+       uchar *loc = serialized+1;
 
        if ( ! lwgeom_hasSRID(type)) return -1;
 
@@ -1739,8 +1748,8 @@ int lwgeom_getsrid(char *serialized)
 // none present => -1
 int pglwgeom_getSRID(PG_LWGEOM *lwgeom)
 {
-       unsigned char type = lwgeom->type;
-       char *loc = lwgeom->data;
+       uchar type = lwgeom->type;
+       uchar *loc = lwgeom->data;
 
        if ( ! lwgeom_hasSRID(type)) return -1;
 
@@ -1758,11 +1767,11 @@ int pglwgeom_getSRID(PG_LWGEOM *lwgeom)
 PG_LWGEOM *
 pglwgeom_setSRID(PG_LWGEOM *lwgeom, int32 newSRID)
 {
-       unsigned char type = lwgeom->type;
+       uchar type = lwgeom->type;
        int bbox_offset=0; //0=no bbox, otherwise sizeof(BOX2DFLOAT4)
        int len,len_new,len_left;
        PG_LWGEOM *result;
-       char *loc_new, *loc_old;
+       uchar *loc_new, *loc_old;
 
        if (lwgeom_hasBBOX(type))
                bbox_offset = sizeof(BOX2DFLOAT4);
@@ -1847,10 +1856,10 @@ pglwgeom_setSRID(PG_LWGEOM *lwgeom, int32 newSRID)
 }
 
 PG_LWGEOM *
-PG_LWGEOM_construct(char *ser, int SRID, int wantbbox)
+PG_LWGEOM_construct(uchar *ser, int SRID, int wantbbox)
 {
        int size;
-       char *iptr, *optr, *eptr;
+       uchar *iptr, *optr, *eptr;
        int wantsrid = 0;
        BOX2DFLOAT4 box;
        PG_LWGEOM *result;
@@ -1929,7 +1938,7 @@ pfree_exploded(LWGEOM_EXPLODED *exploded)
  * and returns a list of _all_ subgeoms in it (deep-first)
  */
 LWGEOM_EXPLODED *
-lwgeom_explode(char *serialized)
+lwgeom_explode(uchar *serialized)
 {
        LWGEOM_INSPECTED *inspected;
        LWGEOM_EXPLODED *subexploded, *result;
@@ -1972,7 +1981,7 @@ lwnotice("lwgeom_explode: serialized inspected");
        for (i=0; i<inspected->ngeometries; i++)
        {
 
-               char *subgeom = inspected->sub_geoms[i];
+               uchar *subgeom = inspected->sub_geoms[i];
                int type = lwgeom_getType(subgeom[0]);
 
                if ( type == POINTTYPE )
@@ -1981,7 +1990,7 @@ lwnotice("lwgeom_explode: serialized inspected");
 lwnotice("lwgeom_explode: it's a point");
 #endif
                        result->points = lwrealloc(result->points,
-                               (result->npoints+1)*sizeof(char *));
+                               (result->npoints+1)*sizeof(uchar *));
                        result->points[result->npoints] = subgeom;
                        result->npoints++;
                        continue;
@@ -1993,7 +2002,7 @@ lwnotice("lwgeom_explode: it's a point");
 lwnotice("lwgeom_explode: it's a line");
 #endif
                        result->lines = lwrealloc(result->lines,
-                               (result->nlines+1)*sizeof(char *));
+                               (result->nlines+1)*sizeof(uchar *));
                        result->lines[result->nlines] = subgeom;
                        result->nlines++;
                        continue;
@@ -2005,7 +2014,7 @@ lwnotice("lwgeom_explode: it's a line");
 lwnotice("lwgeom_explode: it's a polygon");
 #endif
                        result->polys = lwrealloc(result->polys,
-                               (result->npolys+1)*sizeof(char *));
+                               (result->npolys+1)*sizeof(uchar *));
                        result->polys[result->npolys] = subgeom;
                        result->npolys++;
                        continue;
@@ -2030,7 +2039,7 @@ lwnotice("lwgeom_explode: it's a polygon");
                if ( subexploded->npoints )
                {
                        result->points = lwrealloc(result->points,
-                               sizeof(char *)*(result->npoints+subexploded->npoints-1));
+                               sizeof(uchar *)*(result->npoints+subexploded->npoints-1));
                        if ( ! result )
                                lwerror("Out of virtual memory");
 
@@ -2040,7 +2049,7 @@ lwnotice("lwgeom_explode: it's a polygon");
 
                        memcpy(&(result->points[result->npoints]),
                                subexploded->points,
-                               subexploded->npoints*sizeof(char *));
+                               subexploded->npoints*sizeof(uchar *));
 
 #ifdef PGIS_DEBUG
                        lwnotice("memcpied exploded->points");
@@ -2056,12 +2065,12 @@ lwnotice("lwgeom_explode: it's a polygon");
                if ( subexploded->nlines )
                {
                        result->lines = lwrealloc(result->lines,
-                               sizeof(char *)*
+                               sizeof(uchar *)*
                                (result->nlines+subexploded->nlines-1));
 
                        memcpy(&(result->lines[result->nlines]),
                                subexploded->lines,
-                               subexploded->nlines*sizeof(char *));
+                               subexploded->nlines*sizeof(uchar *));
 
                        result->nlines += subexploded->nlines;
                }
@@ -2069,12 +2078,12 @@ lwnotice("lwgeom_explode: it's a polygon");
                if ( subexploded->npolys )
                {
                        result->polys = lwrealloc(result->polys,
-                               sizeof(char *)*
+                               sizeof(uchar *)*
                                (result->npolys+subexploded->npolys-1));
 
                        memcpy(&(result->polys[result->npolys]),
                                subexploded->polys,
-                               subexploded->npolys*sizeof(char *));
+                               subexploded->npolys*sizeof(uchar *));
 
                        result->npolys += subexploded->npolys;
                }
@@ -2099,7 +2108,7 @@ LWGEOM_EXPLODED *
 lwexploded_sum(LWGEOM_EXPLODED *exp1, LWGEOM_EXPLODED *exp2)
 {
        LWGEOM_EXPLODED *expcoll;
-       char *loc;
+       uchar *loc;
 
        if ( TYPE_GETZM(exp1->dims) != TYPE_GETZM(exp2->dims) )
        {
@@ -2118,7 +2127,7 @@ lwexploded_sum(LWGEOM_EXPLODED *exp1, LWGEOM_EXPLODED *exp2)
 
        expcoll->npoints = exp1->npoints + exp2->npoints;
        if ( expcoll->npoints ) {
-               expcoll->points = (char **)lwalloc(expcoll->npoints*sizeof(char *));
+               expcoll->points = lwalloc(expcoll->npoints*sizeof(char *));
                loc = (char *)&(expcoll->points[0]);
                if ( exp1->npoints ) {
                        memcpy(loc, exp1->points,
@@ -2170,12 +2179,12 @@ lwexploded_sum(LWGEOM_EXPLODED *exp1, LWGEOM_EXPLODED *exp2)
 /*
  * Serialized a LWGEOM_EXPLODED structure
  */
-char *
+uchar *
 lwexploded_serialize(LWGEOM_EXPLODED *exploded, int wantbbox)
 {
        size_t sizecom = 0;
        size_t size;
-       char *result;
+       uchar *result;
 
        size = lwexploded_findlength(exploded, wantbbox);
        result = lwalloc(size);
@@ -2194,13 +2203,13 @@ lwexploded_serialize(LWGEOM_EXPLODED *exploded, int wantbbox)
  */
 void
 lwexploded_serialize_buf(LWGEOM_EXPLODED *exploded, int wantbbox,
-       char *buf, size_t *retsize)
+       uchar *buf, size_t *retsize)
 {
        size_t size=0;
        int i;
        int ntypes = 0;
        int ngeoms = 0;
-       char *loc;
+       uchar *loc;
        int outtype = 0;
        LWPOLY *poly;
        LWLINE *line;
@@ -2437,7 +2446,7 @@ lwexploded_serialize_buf(LWGEOM_EXPLODED *exploded, int wantbbox,
 
 #ifdef PGIS_DEBUG_EXPLODED
 void
-checkexplodedsize(char *srl, LWGEOM_EXPLODED *exp, int alloced, char wantbbox)
+checkexplodedsize(uchar *srl, LWGEOM_EXPLODED *exp, int alloced, char wantbbox)
 {
        lwnotice("exploded len: serialized:%d computed:%d alloced:%d",
                lwgeom_size(srl), lwexploded_findlength(exp, wantbbox),
@@ -2626,8 +2635,8 @@ box2d_union_p(BOX2DFLOAT4 *b1, BOX2DFLOAT4 *b2, BOX2DFLOAT4 *ubox)
        return 1;
 }
 
-const char *
-lwgeom_typeflags(unsigned char type)
+const uchar *
+lwgeom_typeflags(uchar type)
 {
        static char flags[5];
        int flagno=0;
@@ -2642,13 +2651,13 @@ lwgeom_typeflags(unsigned char type)
 
 //given a string with at least 2 chars in it, convert them to
 // a byte value.  No error checking done!
-unsigned char
+uchar
 parse_hex(char *str)
 {
        //do this a little brute force to make it faster
 
-       unsigned char           result_high = 0;
-       unsigned char           result_low = 0;
+       uchar           result_high = 0;
+       uchar           result_low = 0;
 
        switch (str[0])
        {
@@ -2752,7 +2761,7 @@ parse_hex(char *str)
                        result_low = 15;
                        break;
        }
-       return (unsigned char) ((result_high<<4) + result_low);
+       return (uchar) ((result_high<<4) + result_low);
 }
 
 
@@ -2762,7 +2771,7 @@ parse_hex(char *str)
 //             -> mystr[0] = 'F' and mystr[1] = 'F'
 // no error checking done
 void
-deparse_hex(unsigned char str, unsigned char *result)
+deparse_hex(uchar str, uchar *result)
 {
        int     input_high;
        int  input_low;
@@ -2875,10 +2884,10 @@ deparse_hex(unsigned char str, unsigned char *result)
        }
 }
 
-char *
+uchar *
 parse_lwgeom_wkt(char *wkt_input)
 {
-       char *serialized_form = parse_lwg((const char *)wkt_input,
+       uchar *serialized_form = parse_lwg(wkt_input,
                lwalloc, lwerror);
 
 
index 3ed77408dbec47ed37d4c21850313b5b6e10bd33..b540a0d57a7d69c295c9c5e801a3ebfed0d31fd9 100644 (file)
@@ -15,8 +15,8 @@
 #include "liblwgeom.h"
 
 // External functions (what's again the reason for using explicit hex form ?)
-extern void deparse_hex(unsigned char str, unsigned char *result);
-extern unsigned char parse_hex(char *str);
+extern void deparse_hex(uchar str, uchar *result);
+extern uchar parse_hex(char *str);
 
 // Internal funcs
 void swap_char(char *a,char *b);
@@ -69,7 +69,7 @@ Datum CHIP_in(PG_FUNCTION_ARGS)
        
        for (t=0;t<size;t++)
        {
-               ((unsigned char *)result)[t] = parse_hex( &str[t*2]) ;
+               ((uchar *)result)[t] = parse_hex( &str[t*2]) ;
        }
 // if endian is wrong, flip it otherwise do nothing
        result->size = size;
@@ -148,7 +148,7 @@ Datum CHIP_out(PG_FUNCTION_ARGS)
 
        for (t=0; t< (chip->size); t++)
        {
-               deparse_hex( ((unsigned char *) chip)[t], &result[t*2]);
+               deparse_hex( ((uchar *) chip)[t], &result[t*2]);
        }
        PG_RETURN_CSTRING(result);      
 }
index 68443f9ec724fe2c9a781ca518629bbcf9d21d1f..95e598d0397a3c02b15566afcec302b5f8afa4ab 100644 (file)
@@ -156,7 +156,7 @@ Datum lwhistogram2d_in(PG_FUNCTION_ARGS)
 
        int t;
 
-       while (isspace((unsigned char) *str))
+       while (isspace(*str))
                str++;
 
        if (strstr(str,"HISTOGRAM2D(") != str)
@@ -2453,6 +2453,10 @@ Datum LWGEOM_estimated_extent(PG_FUNCTION_ARGS)
 
 /**********************************************************************
  * $Log$
+ * Revision 1.23  2005/02/10 10:52:53  strk
+ * Changed 'char' to 'uchar' (unsigned char typedef) wherever octet is actually
+ * meant to be.
+ *
  * Revision 1.22  2005/01/13 18:26:49  strk
  * estimated_extent() implemented for PG<80
  *
index ca3eaee1b88767e9a3a1860340539220234475b4..86d0ffd1d3c5e647eb18c664fb208fcc2779f085 100644 (file)
@@ -108,7 +108,7 @@ lwgeom_translate_ptarray(POINTARRAY *pa, double xoff, double yoff, double zoff)
 }
 
 void
-lwgeom_translate_recursive(char *serialized,
+lwgeom_translate_recursive(uchar *serialized,
        double xoff, double yoff, double zoff)
 {
        LWGEOM_INSPECTED *inspected;
@@ -122,7 +122,7 @@ lwgeom_translate_recursive(char *serialized,
                LWLINE *line=NULL;
                LWPOINT *point=NULL;
                LWPOLY *poly=NULL;
-               char *subgeom=NULL;
+               uchar *subgeom=NULL;
 
                point = lwgeom_getpoint_inspected(inspected, i);
                if (point !=NULL)
@@ -244,7 +244,7 @@ Datum postgis_autocache_bbox(PG_FUNCTION_ARGS)
  * Recursively count points in a SERIALIZED lwgeom
  */
 int32
-lwgeom_npoints(char *serialized)
+lwgeom_npoints(uchar *serialized)
 {
        LWGEOM_INSPECTED *inspected = lwgeom_inspect(serialized);
        int i, j;
@@ -256,7 +256,7 @@ lwgeom_npoints(char *serialized)
                LWLINE *line=NULL;
                LWPOINT *point=NULL;
                LWPOLY *poly=NULL;
-               char *subgeom=NULL;
+               uchar *subgeom=NULL;
 
                point = lwgeom_getpoint_inspected(inspected, i);
                if (point !=NULL)
@@ -299,7 +299,7 @@ lwgeom_npoints(char *serialized)
  * Recursively count rings in a SERIALIZED lwgeom
  */
 int32
-lwgeom_nrings_recursive(char *serialized)
+lwgeom_nrings_recursive(uchar *serialized)
 {
        LWGEOM_INSPECTED *inspected;
        int i;
@@ -311,7 +311,7 @@ lwgeom_nrings_recursive(char *serialized)
        for (i=0; i<inspected->ngeometries; i++)
        {
                LWPOLY *poly=NULL;
-               char *subgeom=NULL;
+               uchar *subgeom=NULL;
 
                subgeom = lwgeom_getsubgeometry_inspected(inspected, i);
 
@@ -501,7 +501,7 @@ Datum LWGEOM_perimeter2d_poly(PG_FUNCTION_ARGS)
  * Return number bytes written in given int pointer.
  */
 void
-lwgeom_force2d_recursive(char *serialized, char *optr, size_t *retsize)
+lwgeom_force2d_recursive(uchar *serialized, uchar *optr, size_t *retsize)
 {
        LWGEOM_INSPECTED *inspected;
        int i;
@@ -511,7 +511,7 @@ lwgeom_force2d_recursive(char *serialized, char *optr, size_t *retsize)
        LWPOINT *point = NULL;
        LWLINE *line = NULL;
        LWPOLY *poly = NULL;
-       char *loc;
+       uchar *loc;
 
                
 #ifdef PGIS_DEBUG
@@ -598,7 +598,7 @@ elog(NOTICE, " collection header size:%d", totsize);
        inspected = lwgeom_inspect(serialized);
        for (i=0; i<inspected->ngeometries; i++)
        {
-               char *subgeom = lwgeom_getsubgeometry_inspected(inspected, i);
+               uchar *subgeom = lwgeom_getsubgeometry_inspected(inspected, i);
                lwgeom_force2d_recursive(subgeom, optr, &size);
                totsize += size;
                optr += size;
@@ -619,7 +619,7 @@ elog(NOTICE, " elem %d size: %d (tot: %d)", i, size, totsize);
  * Return number bytes written in given int pointer.
  */
 void
-lwgeom_force3dz_recursive(char *serialized, char *optr, size_t *retsize)
+lwgeom_force3dz_recursive(uchar *serialized, uchar *optr, size_t *retsize)
 {
        LWGEOM_INSPECTED *inspected;
        int i,j,k;
@@ -631,7 +631,7 @@ lwgeom_force3dz_recursive(char *serialized, char *optr, size_t *retsize)
        LWPOLY *poly = NULL;
        POINTARRAY newpts;
        POINTARRAY **nrings;
-       char *loc;
+       uchar *loc;
 
                
 #ifdef PGIS_DEBUG
@@ -759,7 +759,7 @@ elog(NOTICE, " collection header size:%d", totsize);
        inspected = lwgeom_inspect(serialized);
        for (i=0; i<inspected->ngeometries; i++)
        {
-               char *subgeom = lwgeom_getsubgeometry_inspected(inspected, i);
+               uchar *subgeom = lwgeom_getsubgeometry_inspected(inspected, i);
                lwgeom_force3dz_recursive(subgeom, optr, &size);
                totsize += size;
                optr += size;
@@ -780,21 +780,21 @@ elog(NOTICE, " elem %d size: %d (tot: %d)", i, size, totsize);
  * Return number bytes written in given int pointer.
  */
 void
-lwgeom_force3dm_recursive(unsigned char *serialized, char *optr, size_t *retsize)
+lwgeom_force3dm_recursive(uchar *serialized, uchar *optr, size_t *retsize)
 {
        LWGEOM_INSPECTED *inspected;
        int i,j,k;
        size_t totsize=0;
        size_t size=0;
        int type;
-       unsigned char newtypefl;
+       uchar newtypefl;
        LWPOINT *point = NULL;
        LWLINE *line = NULL;
        LWPOLY *poly = NULL;
        POINTARRAY newpts;
        POINTARRAY **nrings;
        POINT3DM *p3dm;
-       char *loc;
+       uchar *loc;
        char check;
 
                
@@ -970,7 +970,7 @@ lwnotice("lwgeom_force3dm_recursive: it's a collection (%s)", lwgeom_typename(ty
        inspected = lwgeom_inspect(serialized);
        for (i=0; i<inspected->ngeometries; i++)
        {
-               char *subgeom = lwgeom_getsubgeometry_inspected(inspected, i);
+               uchar *subgeom = lwgeom_getsubgeometry_inspected(inspected, i);
                lwgeom_force3dm_recursive(subgeom, optr, &size);
                totsize += size;
                optr += size;
@@ -996,7 +996,7 @@ lwnotice("lwgeom_force3dm_recursive returning");
  * Return number bytes written in given int pointer.
  */
 void
-lwgeom_force4d_recursive(char *serialized, char *optr, size_t *retsize)
+lwgeom_force4d_recursive(uchar *serialized, uchar *optr, size_t *retsize)
 {
        LWGEOM_INSPECTED *inspected;
        int i,j,k;
@@ -1008,7 +1008,7 @@ lwgeom_force4d_recursive(char *serialized, char *optr, size_t *retsize)
        LWPOLY *poly = NULL;
        POINTARRAY newpts;
        POINTARRAY **nrings;
-       char *loc;
+       uchar *loc;
 
                
 #ifdef PGIS_DEBUG
@@ -1138,7 +1138,7 @@ elog(NOTICE, " collection header size:%d", totsize);
        inspected = lwgeom_inspect(serialized);
        for (i=0; i<inspected->ngeometries; i++)
        {
-               char *subgeom = lwgeom_getsubgeometry_inspected(inspected, i);
+               uchar *subgeom = lwgeom_getsubgeometry_inspected(inspected, i);
                lwgeom_force4d_recursive(subgeom, optr, &size);
                totsize += size;
                optr += size;
@@ -1156,7 +1156,7 @@ PG_FUNCTION_INFO_V1(LWGEOM_force_2d);
 Datum LWGEOM_force_2d(PG_FUNCTION_ARGS)
 {
        PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
-       char *srl;
+       uchar *srl;
        PG_LWGEOM *result;
        size_t size = 0;
 
@@ -1164,7 +1164,7 @@ Datum LWGEOM_force_2d(PG_FUNCTION_ARGS)
        if ( lwgeom_ndims(geom->type) == 2 ) PG_RETURN_POINTER(geom);
 
        // allocate a larger for safety and simplicity
-       srl = (char *) lwalloc(geom->size);
+       srl = lwalloc(geom->size);
 
        lwgeom_force2d_recursive(SERIALIZED_FORM(geom),
                srl, &size);
@@ -1180,7 +1180,7 @@ PG_FUNCTION_INFO_V1(LWGEOM_force_3dz);
 Datum LWGEOM_force_3dz(PG_FUNCTION_ARGS)
 {
        PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
-       char *srl;
+       uchar *srl;
        PG_LWGEOM *result;
        int olddims;
        size_t size = 0;
@@ -1191,10 +1191,10 @@ Datum LWGEOM_force_3dz(PG_FUNCTION_ARGS)
        if ( olddims == 3 && TYPE_HASZ(geom->type) ) PG_RETURN_POINTER(geom);
 
        if ( olddims > 3 ) {
-               srl = (char *) lwalloc(geom->size);
+               srl = lwalloc(geom->size);
        } else {
                // allocate double as memory a larger for safety 
-               srl = (char *) lwalloc(geom->size*1.5);
+               srl = lwalloc(geom->size*1.5);
        }
 
        lwgeom_force3dz_recursive(SERIALIZED_FORM(geom),
@@ -1211,7 +1211,7 @@ PG_FUNCTION_INFO_V1(LWGEOM_force_3dm);
 Datum LWGEOM_force_3dm(PG_FUNCTION_ARGS)
 {
        PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
-       char *srl;
+       uchar *srl;
        PG_LWGEOM *result;
        int olddims;
        size_t size = 0;
@@ -1227,7 +1227,7 @@ Datum LWGEOM_force_3dm(PG_FUNCTION_ARGS)
                // allocate double as memory a larger for safety 
                size = geom->size * 1.5;
        }
-       srl = (char *)lwalloc(size);
+       srl = lwalloc(size);
 
 #ifdef PGIS_DEBUG
        lwnotice("LWGEOM_force_3dm: allocated %d bytes for result", size);
@@ -1251,7 +1251,7 @@ PG_FUNCTION_INFO_V1(LWGEOM_force_4d);
 Datum LWGEOM_force_4d(PG_FUNCTION_ARGS)
 {
        PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
-       char *srl;
+       uchar *srl;
        PG_LWGEOM *result;
        int olddims;
        size_t size = 0;
@@ -1262,7 +1262,7 @@ Datum LWGEOM_force_4d(PG_FUNCTION_ARGS)
        if ( olddims == 4 ) PG_RETURN_POINTER(geom);
 
        // allocate double as memory a larger for safety 
-       srl = (char *)lwalloc(geom->size*2);
+       srl = lwalloc(geom->size*2);
 
        lwgeom_force4d_recursive(SERIALIZED_FORM(geom),
                srl, &size);
@@ -1414,7 +1414,7 @@ PG_FUNCTION_INFO_V1(LWGEOM_translate);
 Datum LWGEOM_translate(PG_FUNCTION_ARGS)
 {
        PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0));
-       char *srl = SERIALIZED_FORM(geom);
+       uchar *srl = SERIALIZED_FORM(geom);
        BOX2DFLOAT4 *box;
 
        double xoff =  PG_GETARG_FLOAT8(1);
@@ -1654,7 +1654,7 @@ Datum LWGEOM_accum(PG_FUNCTION_ARGS)
                elog(NOTICE, "geom_accum: adding %p (nelems=%d; nbytes=%d)",
                        geom, nelems, nbytes);
 #endif
-               result = (ArrayType *) lwalloc(nbytes);
+               result = lwalloc(nbytes);
                if ( ! result )
                {
                        elog(ERROR, "Out of virtual memory");
@@ -1693,8 +1693,8 @@ Datum LWGEOM_accum(PG_FUNCTION_ARGS)
 #ifdef PGIS_DEBUG
                elog(NOTICE, " array start  @ %p", result);
                elog(NOTICE, " ARR_DATA_PTR @ %p (%d)",
-                       ARR_DATA_PTR(result), (char *)ARR_DATA_PTR(result)-(char *)result);
-               elog(NOTICE, " next element @ %p", (char *)result+oldsize);
+                       ARR_DATA_PTR(result), (uchar *)ARR_DATA_PTR(result)-(uchar *)result);
+               elog(NOTICE, " next element @ %p", (uchar *)result+oldsize);
 #endif
                result->size = nbytes;
                memcpy(ARR_DIMS(result), &nelems, sizeof(int));
@@ -1702,7 +1702,7 @@ Datum LWGEOM_accum(PG_FUNCTION_ARGS)
                elog(NOTICE, " writing next element starting @ %p",
                        result+oldsize);
 #endif
-               memcpy((char *)result+oldsize, geom, geom->size);
+               memcpy((uchar *)result+oldsize, geom, geom->size);
        }
 
 #ifdef PGIS_DEBUG
@@ -2149,7 +2149,7 @@ Datum LWGEOM_expand(PG_FUNCTION_ARGS)
 
        // Construct point array
        pa[0] = lwalloc(sizeof(POINTARRAY));
-       pa[0]->serialized_pointlist = (char *)pts;
+       pa[0]->serialized_pointlist = (uchar *)pts;
        TYPE_SETZM(pa[0]->dims, 0, 0);
        pa[0]->npoints = 5;
 
@@ -2192,7 +2192,7 @@ Datum LWGEOM_envelope(PG_FUNCTION_ARGS)
        LWPOLY *poly;
        int SRID;
        PG_LWGEOM *result;
-       char *ser;
+       uchar *ser;
 
        // get bounding box 
        if ( ! getbox2d_p(SERIALIZED_FORM(geom), &box) )
@@ -2213,7 +2213,7 @@ Datum LWGEOM_envelope(PG_FUNCTION_ARGS)
 
        // Construct point array
        pa[0] = lwalloc(sizeof(POINTARRAY));
-       pa[0]->serialized_pointlist = (char *)pts;
+       pa[0]->serialized_pointlist = (uchar *)pts;
        TYPE_SETZM(pa[0]->dims, 0, 0);
        pa[0]->npoints = 5;
 
@@ -2256,7 +2256,7 @@ Datum centroid(PG_FUNCTION_ARGS)
        POINT3DZ *p, cent;
        int i,j,k;
        uint32 num_points_tot = 0;
-       char *srl;
+       uchar *srl;
        char wantbbox = 0;
        double tot_x=0, tot_y=0, tot_z=0;
 
@@ -2289,7 +2289,7 @@ Datum centroid(PG_FUNCTION_ARGS)
        cent.z = tot_z/num_points_tot;
 
        // Construct POINTARRAY (paranoia?)
-       pa = pointArray_construct((char *)&cent, 1, 0, 1);
+       pa = pointArray_construct((uchar *)&cent, 1, 0, 1);
 
        // Construct LWPOINT
        point = lwpoint_construct(SRID, NULL, pa);
@@ -2394,7 +2394,7 @@ PG_FUNCTION_INFO_V1(LWGEOM_zmflag);
 Datum LWGEOM_zmflag(PG_FUNCTION_ARGS)
 {
        PG_LWGEOM *in;
-       unsigned char type;
+       uchar type;
        int ret = 0;
 
        in = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
index 07050d213a2612ec49656c786245df68567de322..2ed26fd7e5266e12ebf1c1712f725ed86f040d69 100644 (file)
@@ -48,7 +48,7 @@ Datum LWGEOM_send(PG_FUNCTION_ARGS);
 // WKB structure  -- exactly the same as TEXT
 typedef struct Well_known_bin {
     int32 size;             // total size of this structure
-    unsigned char  data[1]; //THIS HOLD VARIABLE LENGTH DATA
+    uchar  data[1]; //THIS HOLD VARIABLE LENGTH DATA
 } WellKnownBinary;
 
 
@@ -180,7 +180,7 @@ Datum LWGEOMFromWKB(PG_FUNCTION_ARGS)
 
        for (t=0; t< (wkb_input->size -VARHDRSZ); t++)
        {
-               deparse_hex( ((unsigned char *) wkb_input)[4 + t], &loc[t*2]);
+               deparse_hex( ((uchar *) wkb_input)[4 + t], &loc[t*2]);
        }
 
        wkb_srid_hexized[size_result-1] = 0; // null term
@@ -280,7 +280,7 @@ Datum WKBFromLWGEOM(PG_FUNCTION_ARGS)
        // have a hexized string, want to make it binary
        for (t=0; t< (size/2); t++)
        {
-               ((unsigned char *) result +VARHDRSZ)[t] = parse_hex(  hexized_wkb + (t*2) );
+               ((uchar *) result +VARHDRSZ)[t] = parse_hex(  hexized_wkb + (t*2) );
        }
 
        pfree(hexized_wkb_srid);
@@ -319,7 +319,7 @@ Datum LWGEOM_addBBOX(PG_FUNCTION_ARGS)
        PG_LWGEOM *lwgeom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
        PG_LWGEOM *result;
        BOX2DFLOAT4     box;
-       unsigned char   old_type;
+       uchar   old_type;
        int             size;
 
 //elog(NOTICE,"in LWGEOM_addBBOX");
@@ -377,12 +377,12 @@ is_worth_caching_pglwgeom_bbox(const PG_LWGEOM *in)
 }
 
 char
-is_worth_caching_serialized_bbox(const char *in)
+is_worth_caching_serialized_bbox(const uchar *in)
 {
 #if ! AUTOCACHE_BBOX
        return false;
 #endif
-       if ( TYPE_GETTYPE((unsigned char)in[0]) == POINTTYPE ) return false;
+       if ( TYPE_GETTYPE((uchar)in[0]) == POINTTYPE ) return false;
        return true;
 }
 
@@ -402,8 +402,8 @@ Datum LWGEOM_dropBBOX(PG_FUNCTION_ARGS)
 {
        PG_LWGEOM *lwgeom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
        PG_LWGEOM *result;
-       unsigned char   old_type;
-       int             size;
+       uchar old_type;
+       int size;
 
 //elog(NOTICE,"in LWGEOM_dropBBOX");
 
index 941a87a4244cf31024876afb495514f60ebeeb4f..a26761236c58ba7679b29d13d2780ff01df67f24 100644 (file)
@@ -102,7 +102,7 @@ Datum LWGEOM_getTYPE(PG_FUNCTION_ARGS)
        char *text_ob;
        char *result;
        int32 size;
-       unsigned char type;
+       uchar type;
 
        init_pg_func();
 
index 066485f42c1486bfea198a6880210476e2c7b2bc..d9a7ddd3c23a25b76269a4a684beb4c40f1fd501 100644 (file)
@@ -34,15 +34,15 @@ lwline_construct(int SRID, BOX2DFLOAT4 *bbox, POINTARRAY *points)
 // serialized_form should point to the 8bit type format (with type = 2)
 // See serialized form doc
 LWLINE *
-lwline_deserialize(char *serialized_form)
+lwline_deserialize(uchar *serialized_form)
 {
-       unsigned char type;
+       uchar type;
        LWLINE *result;
-       char *loc =NULL;
+       uchar *loc =NULL;
        uint32 npoints;
        POINTARRAY *pa;
 
-       type = (unsigned char) serialized_form[0];
+       type = (uchar) serialized_form[0];
 
        if ( lwgeom_getType(type) != LINETYPE)
        {
@@ -92,11 +92,11 @@ lwline_deserialize(char *serialized_form)
 
 // convert this line into its serialize form
 // result's first char will be the 8bit type.  See serialized form doc
-char *
+uchar *
 lwline_serialize(LWLINE *line)
 {
        size_t size, retsize;
-       char * result;
+       uchar * result;
 
        if (line == NULL) lwerror("lwline_serialize:: given null line");
 
@@ -117,10 +117,10 @@ lwline_serialize(LWLINE *line)
 // the given int pointer.
 // result's first char will be the 8bit type.  See serialized form doc
 void
-lwline_serialize_buf(LWLINE *line, char *buf, size_t *retsize)
+lwline_serialize_buf(LWLINE *line, uchar *buf, size_t *retsize)
 {
        char hasSRID;
-       char *loc;
+       uchar *loc;
        int ptsize = pointArray_ptsize(line->points);
        unsigned int u;
 
@@ -134,7 +134,7 @@ lwline_serialize_buf(LWLINE *line, char *buf, size_t *retsize)
 
        hasSRID = (line->SRID != -1);
 
-       buf[0] = (unsigned char) lwgeom_makeType_full(
+       buf[0] = (uchar) lwgeom_makeType_full(
                TYPE_HASZ(line->type), TYPE_HASM(line->type),
                hasSRID, LINETYPE, line->bbox ? 1 : 0);
        loc = buf+1;
@@ -213,7 +213,7 @@ lwline_serialize_buf(LWLINE *line, char *buf, size_t *retsize)
 
        if (retsize) *retsize = loc-buf;
 
-       //printBYTES((unsigned char *)result, loc-buf);
+       //printBYTES((uchar *)result, loc-buf);
 
 #ifdef PGIS_DEBUG_CALLS
        lwnotice("lwline_serialize_buf returning (loc: %p, size: %d)",
@@ -265,11 +265,11 @@ void pfree_line (LWLINE  *line)
 
 // find length of this serialized line
 size_t
-lwgeom_size_line(const char *serialized_line)
+lwgeom_size_line(const uchar *serialized_line)
 {
-       int type = (unsigned char) serialized_line[0];
+       int type = (uchar) serialized_line[0];
        uint32 result = 1;  //type
-       const char *loc;
+       const uchar *loc;
        uint32 npoints;
 
 #ifdef PGIS_DEBUG_CALLS
index 5a98c897aa1334e3a861da693285903d7546508c..d5a78d00e1a7611c10df8155ced972a434e9a59a 100644 (file)
@@ -4,7 +4,7 @@
 #include "liblwgeom.h"
 
 LWMLINE *
-lwmline_deserialize(char *srl)
+lwmline_deserialize(uchar *srl)
 {
        LWMLINE *result;
        LWGEOM_INSPECTED *insp;
index a6562d233077ee41f807b64d5fe3eb6922aeeba1..48463e65e9924d468e8dd09410663db9daaf3d26 100644 (file)
@@ -4,7 +4,7 @@
 #include "liblwgeom.h"
 
 LWMPOINT *
-lwmpoint_deserialize(char *srl)
+lwmpoint_deserialize(uchar *srl)
 {
        LWMPOINT *result;
        LWGEOM_INSPECTED *insp;
index e9654976320bccd130861349aa0b61caa9f2e607..ed797fb12335e9131af1fa0831fa9f812826a0c4 100644 (file)
@@ -6,7 +6,7 @@
 //#define PGIS_DEBUG_CALLS 1
 
 LWMPOLY *
-lwmpoly_deserialize(char *srl)
+lwmpoly_deserialize(uchar *srl)
 {
        LWMPOLY *result;
        LWGEOM_INSPECTED *insp;
index 9ed3d006620d850e82ca35e9ea92ecc71ade202e..49ead83f9dcee2ace704650d3124beec859dab1c 100644 (file)
@@ -7,11 +7,11 @@
 
 // convert this point into its serialize form
 // result's first char will be the 8bit type.  See serialized form doc
-char *
+uchar *
 lwpoint_serialize(LWPOINT *point)
 {
        size_t size, retsize;
-       char *result;
+       uchar *result;
 
        size = lwpoint_serialize_size(point);
        result = lwalloc(size);
@@ -30,11 +30,11 @@ lwpoint_serialize(LWPOINT *point)
 // the given int pointer.
 // result's first char will be the 8bit type.  See serialized form doc
 void
-lwpoint_serialize_buf(LWPOINT *point, char *buf, size_t *retsize)
+lwpoint_serialize_buf(LWPOINT *point, uchar *buf, size_t *retsize)
 {
        int size=1;
        char hasSRID;
-       char *loc;
+       uchar *loc;
 
        //printLWPOINT(point);
 #ifdef PGIS_DEBUG_CALLS
@@ -48,7 +48,7 @@ lwpoint_serialize_buf(LWPOINT *point, char *buf, size_t *retsize)
 
        size += sizeof(double)*TYPE_NDIMS(point->type);
 
-       buf[0] = (unsigned char) lwgeom_makeType_full(
+       buf[0] = (uchar) lwgeom_makeType_full(
                TYPE_HASZ(point->type), TYPE_HASM(point->type),
                hasSRID, POINTTYPE, point->bbox?1:0);
        loc = buf+1;
@@ -219,11 +219,11 @@ make_lwpoint4d(int SRID, double x, double y, double z, double m)
 // serialized_form should point to the 8bit type format (with type = 1)
 // See serialized form doc
 LWPOINT *
-lwpoint_deserialize(char *serialized_form)
+lwpoint_deserialize(uchar *serialized_form)
 {
-       unsigned char type;
+       uchar type;
        LWPOINT *result;
-       char *loc = NULL;
+       uchar *loc = NULL;
        POINTARRAY *pa;
 
 #ifdef PGIS_DEBUG_CALLS
@@ -232,7 +232,7 @@ lwpoint_deserialize(char *serialized_form)
 
        result = (LWPOINT*) lwalloc(sizeof(LWPOINT)) ;
 
-       type = (unsigned char) serialized_form[0];
+       type = (uchar) serialized_form[0];
 
        if ( lwgeom_getType(type) != POINTTYPE) return NULL;
        result->type = type;
@@ -361,13 +361,13 @@ lwpoint_add(const LWPOINT *to, uint32 where, const LWGEOM *what)
 
 //find length of this serialized point
 size_t
-lwgeom_size_point(const char *serialized_point)
+lwgeom_size_point(const uchar *serialized_point)
 {
        uint32  result = 1;
-       unsigned char type;
-       const char *loc;
+       uchar type;
+       const uchar *loc;
 
-       type = (unsigned char) serialized_point[0];
+       type = serialized_point[0];
 
        if ( lwgeom_getType(type) != POINTTYPE) return 0;
 
index 2c713e84e7fb6e65aab195c1b37eba71b8acf22c..20a46dfdeabe0174c50320e3a672d4d28c3e90a5 100644 (file)
@@ -52,14 +52,14 @@ lwpoly_construct(int SRID, BOX2DFLOAT4 *bbox, unsigned int nrings, POINTARRAY **
 // serialized_form should point to the 8bit type format (with type = 3)
 // See serialized form doc
 LWPOLY *
-lwpoly_deserialize(char *serialized_form)
+lwpoly_deserialize(uchar *serialized_form)
 {
 
        LWPOLY *result;
        uint32 nrings;
        int ndims, hasz, hasm;
        uint32 npoints;
-       unsigned char type;
+       uchar type;
        char  *loc;
        int t;
 
@@ -127,11 +127,11 @@ lwpoly_deserialize(char *serialized_form)
 // create the serialized form of the polygon
 // result's first char will be the 8bit type.  See serialized form doc
 // points copied
-char *
+uchar *
 lwpoly_serialize(LWPOLY *poly)
 {
        size_t size, retsize;
-       char *result;
+       uchar *result;
 
        size = lwpoly_serialize_size(poly);
        result = lwalloc(size);
@@ -151,14 +151,14 @@ lwpoly_serialize(LWPOLY *poly)
 // result's first char will be the 8bit type.  See serialized form doc
 // points copied
 void
-lwpoly_serialize_buf(LWPOLY *poly, char *buf, size_t *retsize)
+lwpoly_serialize_buf(LWPOLY *poly, uchar *buf, size_t *retsize)
 {
        int size=1;  // type byte
        char hasSRID;
        int t,u;
        int total_points = 0;
        int npoints;
-       char *loc;
+       uchar *loc;
 
 #ifdef PGIS_DEBUG_CALLS
        lwnotice("lwpoly_serialize_buf called");
@@ -174,7 +174,7 @@ lwpoly_serialize_buf(LWPOLY *poly, char *buf, size_t *retsize)
        }
        size += sizeof(double)*TYPE_NDIMS(poly->type)*total_points;
 
-       buf[0] = (unsigned char) lwgeom_makeType_full(
+       buf[0] = (uchar) lwgeom_makeType_full(
                TYPE_HASZ(poly->type), TYPE_HASM(poly->type),
                hasSRID, POLYGONTYPE, poly->bbox ? 1 : 0);
        loc = buf+1;
@@ -270,21 +270,21 @@ lwpoly_findbbox(LWPOLY *poly)
 
 //find length of this serialized polygon
 size_t
-lwgeom_size_poly(const char *serialized_poly)
+lwgeom_size_poly(const uchar *serialized_poly)
 {
        uint32 result = 1; // char type
        uint32 nrings;
-       int   ndims;
+       int ndims;
        int t;
-       unsigned char type;
+       uchar type;
        uint32 npoints;
-       const char *loc;
+       const uchar *loc;
 
        if (serialized_poly == NULL)
                return -9999;
 
 
-       type = (unsigned char) serialized_poly[0];
+       type = (uchar) serialized_poly[0];
        ndims = lwgeom_ndims(type);
 
        if ( lwgeom_getType(type) != POLYGONTYPE)
index ccbb6abe25f55ca6b7f187bb4d4229b86c4634b4..e406d6740c55e5502d52d1a7e62a9a8ed115eb46 100644 (file)
@@ -581,7 +581,7 @@ double lwgeom_polygon_perimeter2d(LWPOLY *poly)
 }
 
 double
-lwgeom_mindistance2d_recursive(char *lw1, char *lw2)
+lwgeom_mindistance2d_recursive(uchar *lw1, uchar *lw2)
 {
        LWGEOM_INSPECTED *in1, *in2;
        int i, j;
@@ -592,7 +592,7 @@ lwgeom_mindistance2d_recursive(char *lw1, char *lw2)
 
        for (i=0; i<in1->ngeometries; i++)
        {
-               char *g1 = lwgeom_getsubgeometry_inspected(in1, i);
+               uchar *g1 = lwgeom_getsubgeometry_inspected(in1, i);
                int t1 = lwgeom_getType(g1[0]);
                double dist=0;
 
@@ -608,7 +608,7 @@ lwgeom_mindistance2d_recursive(char *lw1, char *lw2)
 
                for (j=0; j<in2->ngeometries; j++)
                {
-                       char *g2 = lwgeom_getsubgeometry_inspected(in2, j);
+                       uchar *g2 = lwgeom_getsubgeometry_inspected(in2, j);
                        int t2 = lwgeom_getType(g2[0]);
 
                        if  ( t1 == POINTTYPE )
index 4767b627438148d343f8b191cbec7fc449783598..b9bc8317df6e4ad976218652c119412760e4feec 100644 (file)
@@ -8,14 +8,15 @@
 POINTARRAY *
 ptarray_construct(char hasz, char hasm, unsigned int npoints)
 {
-       unsigned char dims = 0;
+       uchar dims = 0;
        size_t size; 
-       char *ptlist;
+       uchar *ptlist;
        POINTARRAY *pa;
        
        TYPE_SETZM(dims, hasz?1:0, hasm?1:0);
        size = TYPE_NDIMS(dims)*npoints*sizeof(double);
-       ptlist = (char *)lwalloc(size);
+
+       ptlist = (uchar *)lwalloc(size);
        pa = lwalloc(sizeof(POINTARRAY));
        pa->dims = dims;
        pa->serialized_pointlist = ptlist;
@@ -104,12 +105,12 @@ ptarray_reverse(POINTARRAY *pa)
 
        for (i=0; i<=mid; i++)
        {
-               char *from, *to;
+               uchar *from, *to;
                from = getPoint(pa, i);
                to = getPoint(pa, (last-i));
-               memcpy((char *)&pbuf, to, ptsize);
+               memcpy((uchar *)&pbuf, to, ptsize);
                memcpy(to, from, ptsize);
-               memcpy(from, (char *)&pbuf, ptsize);
+               memcpy(from, (uchar *)&pbuf, ptsize);
        }
 
 }
@@ -197,7 +198,7 @@ ptarray_segmentize2d(POINTARRAY *ipa, double dist)
        opa = (POINTARRAY *)lwalloc(ptsize * maxpoints);
        opa->dims = ipa->dims;
        opa->npoints = 0;
-       opa->serialized_pointlist = (char *)lwalloc(maxpoints*ptsize);
+       opa->serialized_pointlist = (uchar *)lwalloc(maxpoints*ptsize);
 
        // Add first point
        opa->npoints++;
@@ -230,7 +231,7 @@ ptarray_segmentize2d(POINTARRAY *ipa, double dist)
                // Add point
                if ( ++(opa->npoints) > maxpoints ) {
                        maxpoints *= 1.5;
-                       opa->serialized_pointlist = (char *)lwrealloc(
+                       opa->serialized_pointlist = (uchar *)lwrealloc(
                                opa->serialized_pointlist,
                                maxpoints*ptsize
                        );
@@ -269,7 +270,7 @@ ptarray_same(const POINTARRAY *pa1, const POINTARRAY *pa2)
  * if 'where' == -1 append is required.
  */
 POINTARRAY *
-ptarray_addPoint(POINTARRAY *pa, char *p, size_t pdims, unsigned int where)
+ptarray_addPoint(POINTARRAY *pa, uchar *p, size_t pdims, unsigned int where)
 {
        POINTARRAY *ret;
        POINT4D pbuf;
@@ -287,7 +288,7 @@ ptarray_addPoint(POINTARRAY *pa, char *p, size_t pdims, unsigned int where)
 #endif
        
        pbuf.x = pbuf.y = pbuf.z = pbuf.m = 0.0;
-       memcpy((char *)&pbuf, p, pdims*sizeof(double));
+       memcpy((uchar *)&pbuf, p, pdims*sizeof(double));
 
 #if PGIS_DEBUG
        lwnotice("ptarray_addPoint: initialized point buffer");
@@ -303,7 +304,7 @@ ptarray_addPoint(POINTARRAY *pa, char *p, size_t pdims, unsigned int where)
                memcpy(getPoint(ret, 0), getPoint(pa, 0), ptsize*where);
        }
 
-       memcpy(getPoint(ret, where), (char *)&pbuf, ptsize);
+       memcpy(getPoint(ret, where), (uchar *)&pbuf, ptsize);
 
        if ( where+1 != ret->npoints )
        {