From: David Blasby Date: Thu, 11 Mar 2004 01:27:43 +0000 (+0000) Subject: minor clean and trying to figure out a memory bug. valgrind wasnt helping, but X-Git-Tag: pgis_0_8_2~72 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cd94686d55df64ad23ff54711cdce32050c3d909;p=postgis minor clean and trying to figure out a memory bug. valgrind wasnt helping, but it went away. git-svn-id: http://svn.osgeo.org/postgis/trunk@487 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/lwgeom/lwgeom.sql.in b/lwgeom/lwgeom.sql.in index 43f68c74b..9748a1a61 100644 --- a/lwgeom/lwgeom.sql.in +++ b/lwgeom/lwgeom.sql.in @@ -45,3 +45,5 @@ select geometry(wkb(lwgeom(asbinary('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))'::ge select geometry(wkb(lwgeom(asbinary('POLYGON((0 0 -99, 10 0 -99, 10 10 -99, 0 10 -99, 0 0 -99))'::geometry)))); +select geometry(wkb(lwgeom(asbinary('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 5,7 5, 7 7, 5 7, 5 5))'::geometry)))); +select geometry(wkb(lwgeom(asbinary('POLYGON((0 0 -99, 10 0 -99, 10 10 -99, 0 10 -99, 0 0 -99),(5 5 -99,7 5 -99, 7 7 -99, 5 7 -99, 5 5 -99))'::geometry)))); diff --git a/lwgeom/lwgeom_api.c b/lwgeom/lwgeom_api.c index 1afc66122..d04cbb5ef 100644 --- a/lwgeom/lwgeom_api.c +++ b/lwgeom/lwgeom_api.c @@ -492,7 +492,6 @@ LWLINE *lwline_deserialize(char *serialized_form) result->points = pa; result->is3d = lwgeom_is3d(type); -//elog(NOTICE,"npoints in deserialize line = %i",npoints); return result; } @@ -506,7 +505,9 @@ char *lwline_serialize(LWLINE *line) int t; char *loc; -elog(NOTICE,"lwline_serialize::entry"); +if (line == NULL) + elog(ERROR,"lwline_serialize:: given null line"); + hasSRID = (line->SRID != -1); if (hasSRID) @@ -521,9 +522,8 @@ elog(NOTICE,"lwline_serialize::entry"); size += 16 * line->points->npoints; //x,y } - size+=4; // npoints -elog(NOTICE,"lwline_serialize:: size = %i",size); + size+=4; // npoints result = palloc(size); @@ -540,6 +540,8 @@ elog(NOTICE,"lwline_serialize:: size = %i",size); loc +=4; //copy in points +elog(NOTICE," line serialize - size = %i", size); + if (line->is3d) { for (t=0; t< line->points->npoints;t++) @@ -556,7 +558,7 @@ elog(NOTICE,"lwline_serialize:: size = %i",size); loc += 16; // size of a 2d point } } - printBYTES((unsigned char *)result, size); + //printBYTES((unsigned char *)result, size); return result; } @@ -593,7 +595,6 @@ uint32 lwline_findlength(char *serialized_line) // we've read the type (1 byte) and SRID (4 bytes, if present) npoints = get_uint32(loc); -elog(NOTICE,"npoint in lwline_findlength= %i",npoints); result += 4; //npoints if (lwgeom_is3d(type) ) @@ -843,7 +844,6 @@ LWPOLY *lwpoly_deserialize(char *serialized_form) nrings = get_uint32(loc); result->nrings = nrings; loc +=4; -elog(NOTICE,"lwpoly_deserialize:: polygon with %i rings",nrings); result->rings = (POINTARRAY**) palloc(nrings* sizeof(POINTARRAY*)); for (t =0;tis3d,hasSRID, POLYGONTYPE); loc = result+1; @@ -915,7 +914,6 @@ char *lwpoly_serialize(LWPOLY *poly) { POINTARRAY *pa = poly->rings[t]; npoints = poly->rings[t]->npoints; -elog(NOTICE,"doing ring #%i with %i points",t,npoints); memcpy(loc, &npoints, sizeof(int32)); //npoints this ring loc+=4; if (poly->is3d) @@ -930,7 +928,6 @@ elog(NOTICE,"doing ring #%i with %i points",t,npoints); { for (u=0;upoints->npoints); + //printLWLINE(line); result = lwline_serialize(line); - elog(NOTICE,"serialized it"); +// elog(NOTICE,"line serialized"); *size = lwline_findlength(result); - elog(NOTICE,"serialized length=%i",*size); pfree_line(line); break; case POLYGONTYPE: poly = wkb_poly_to_lwpoly(wkb, SRID); - printLWPOLY(poly); +// printLWPOLY(poly); result = lwpoly_serialize(poly); - elog(NOTICE,"serialized polygon"); *size = lwpoly_findlength(result); - elog(NOTICE,"serialized polygon has length = %i",*size); pfree_polygon(poly); break; case MULTIPOINTTYPE: @@ -308,7 +304,7 @@ LWPOINT *wkb_point_to_lwpoint(char *wkb,int SRID) simpletype = wkb_simpletype(wkbtype); #ifdef DEBUG - elog(NOTICE,"wkb_point_to_lwpoint: entry with SRID=%i, dims=%i, simpletype=%i\n",SRID,(int) dims, (int) simpletype); + elog(NOTICE,"wkb_point_to_lwpoint: entry with SRID=%i, dims=%i, simpletype=%i",SRID,(int) dims, (int) simpletype); #endif @@ -352,7 +348,6 @@ LWLINE *wkb_line_to_lwline(char *wkb,int SRID) flipPoints(wkb+9,npoints,dims); pa = pointArray_construct(wkb+9, dims, npoints); -printPA(pa); return lwline_construct(dims, SRID, pa); } @@ -413,7 +408,6 @@ LWPOLY *wkb_poly_to_lwpoly(char *wkb,int SRID) // read a ring if (need_flip) flipPoints(loc+4,npoints,dims); -elog(NOTICE,"wkb_poly_to_lwpoly:: doing ring %i with %i points", t, npoints); pa = pointArray_construct(loc+4, dims, npoints); loc += 4; @@ -439,7 +433,7 @@ char *lwgeom_to_wkb(char *serialized_form,int *wkblength,char desiredWKBEndian) char *multigeom = NULL; #ifdef DEBUG - elog(NOTICE,"lwgeom_to_wkb: entry with simpletype=%i, dims=%i\n",(int) simple_type,(int) lwgeom_is3d( serialized_form[0]) ); + elog(NOTICE,"lwgeom_to_wkb: entry with simpletype=%i, dims=%i",(int) simple_type,(int) lwgeom_is3d( serialized_form[0]) ); #endif @@ -456,9 +450,8 @@ char *lwgeom_to_wkb(char *serialized_form,int *wkblength,char desiredWKBEndian) pfree_line(line); break; case POLYGONTYPE: - elog(NOTICE,"lwgeom_to_wkb :: deserializing polygon"); poly = lwpoly_deserialize(serialized_form); - printLWPOLY(poly); +// printLWPOLY(poly); result = lwpoly_to_wkb(poly, desiredWKBEndian, wkblength); pfree_polygon(poly ); break; @@ -483,7 +476,7 @@ char *lwpoint_to_wkb(LWPOINT *pt, char desiredWKBEndian, int *wkbsize) bool need_flip = requiresflip( desiredWKBEndian ); #ifdef DEBUG - elog(NOTICE,"lwpoint_to_wkb: pa dims = %i\n", (int)pt->point->is3d ); + elog(NOTICE,"lwpoint_to_wkb: pa dims = %i", (int)pt->point->is3d ); #endif @@ -496,7 +489,7 @@ char *lwpoint_to_wkb(LWPOINT *pt, char desiredWKBEndian, int *wkbsize) wkbtype = constructWKBType(POINTTYPE, pt->point->is3d); #ifdef DEBUG - elog(NOTICE,"lwpoint_to_wkb: entry with wkbtype=%i, pa dims = %i\n",wkbtype, (int)pt->point->is3d ); + elog(NOTICE,"lwpoint_to_wkb: entry with wkbtype=%i, pa dims = %i",wkbtype, (int)pt->point->is3d ); #endif @@ -519,9 +512,6 @@ char *lwline_to_wkb(LWLINE *line, char desiredWKBEndian, int *wkbsize) uint32 wkbtype ; bool need_flip = requiresflip( desiredWKBEndian ); - -printLWLINE(line); - *wkbsize = 1+ 4+4+ line->points->npoints * ptsize; //endian, type, npoints, points result = palloc(*wkbsize);