ptarray_from_GEOSCoordSeq(const GEOSCoordSequence* cs, uint8_t want3d)
{
uint32_t dims = 2;
- uint32_t size, i;
+ uint32_t size = 0, i;
POINTARRAY* pa;
- POINT4D point;
+ POINT4D point = { 0.0, 0.0, 0.0, 0.0 };
LWDEBUG(2, "ptarray_fromGEOSCoordSeq called");
shell = ptarray_to_GEOSLinearRing(lwpoly->rings[0], autofix);
if (!shell) return NULL;
ngeoms = lwpoly->nrings - 1;
- if (ngeoms > 0) geoms = malloc(sizeof(GEOSGeom) * ngeoms);
+ if (ngeoms > 0) geoms = lwalloc(sizeof(GEOSGeom) * ngeoms);
for (i = 1; i < lwpoly->nrings; i++)
{
uint32_t k;
for (k = 0; k < i - 1; k++)
GEOSGeom_destroy(geoms[k]);
- free(geoms);
+ lwfree(geoms);
GEOSGeom_destroy(shell);
return NULL;
}
}
g = GEOSGeom_createPolygon(shell, geoms, ngeoms);
- if (geoms) free(geoms);
+ if (geoms) lwfree(geoms);
}
if (!g) return NULL;
break;
lwc = (LWCOLLECTION*)lwgeom;
ngeoms = lwc->ngeoms;
- if (ngeoms > 0) geoms = malloc(sizeof(GEOSGeom) * ngeoms);
+ if (ngeoms > 0) geoms = lwalloc(sizeof(GEOSGeom) * ngeoms);
j = 0;
for (i = 0; i < ngeoms; ++i)
uint32_t k;
for (k = 0; k < j; k++)
GEOSGeom_destroy(geoms[k]);
- free(geoms);
+ lwfree(geoms);
return NULL;
}
geoms[j++] = g;
}
g = GEOSGeom_createCollection(geostype, geoms, j);
- if (ngeoms > 0) free(geoms);
+ if (ngeoms > 0) lwfree(geoms);
if (!g) return NULL;
break;
/* Allocate space for the result. Leave plenty of room for excess digits, negative sign, etc.*/
result = (char*)lwalloc(format_length + WORK_SIZE);
+ memset(result, 0, format_length + WORK_SIZE);
+
/* Append all the pieces together. There may be less than 9, but in that case the rest will be blank. */
strcpy(result, pieces[0]);
for (index = 1; index < NUM_PIECES; index++)
double lon1 = a->lon * 180.0 / M_PI;
double lat2 = b->lat * 180.0 / M_PI;
double lon2 = b->lon * 180.0 / M_PI;
- double s12; /* return distance */
+ double s12 = 0.0; /* return distance */
geod_inverse(&gd, lat1, lon1, lat2, lon2, &s12, 0, 0);
return s12;
}