diff --git a/meos/examples/03_ais_assemble.c b/meos/examples/03_ais_assemble.c index 5ac50c8686..31df8232ac 100644 --- a/meos/examples/03_ais_assemble.c +++ b/meos/examples/03_ais_assemble.c @@ -33,7 +33,7 @@ * instants, and the distance travelled. The program also stores in a CSV file * the assembled trips. * - * Please read the assumptions made about the input file in the file + * Please read the assumptions made about the input file in the file * `02_ais_read.c` in the same directory. Furthermore, the program assumes the * input file contains less than 50K observations for at most five ships. * Also, the program does not cope with erroneous inputs, such as two or more @@ -188,6 +188,7 @@ int main(void) char *t_out = pg_timestamp_out(rec.T); sprintf(point_buffer, "SRID=4326;Point(%lf %lf)@%s+00", rec.Longitude, rec.Latitude, t_out); + free(t_out); TInstant *inst1 = (TInstant *) tgeogpoint_in(point_buffer); trips[ship].trip_instants[trips[ship].numinstants] = inst1; TInstant *inst2 = (TInstant *) tfloatinst_make(rec.SOG, rec.T); diff --git a/meos/examples/04_ais_store.c b/meos/examples/04_ais_store.c index dbec29c35b..ef10ffe04e 100644 --- a/meos/examples/04_ais_store.c +++ b/meos/examples/04_ais_store.c @@ -281,6 +281,7 @@ main(int argc, char **argv) printf("Query 'SELECT COUNT(*) FROM public.AISInstants' returned %s\n", PQgetvalue(res, 0, 0)); + PQclear(res); /* State that the program executed successfully */ exit_value = 0; diff --git a/meos/examples/05_berlinmod_disassemble.c b/meos/examples/05_berlinmod_disassemble.c index 6ce92070d5..878cb182cd 100644 --- a/meos/examples/05_berlinmod_disassemble.c +++ b/meos/examples/05_berlinmod_disassemble.c @@ -91,7 +91,7 @@ int main(void) /* Get start time */ clock_t t; t = clock(); - + /* Initialize MEOS */ meos_initialize(NULL, NULL); @@ -177,7 +177,7 @@ int main(void) if (first == records_in) /* All trips have been processed */ break; - const TInstant *min_inst = temporal_instant_n(trips[first].trip, + TInstant *min_inst = temporal_instant_n(trips[first].trip, curr_inst[first]); int min_trip = first; @@ -186,21 +186,24 @@ int main(void) { if (curr_inst[i] < 0) continue; - const TInstant *inst = temporal_instant_n(trips[i].trip, curr_inst[i]); + TInstant *inst = temporal_instant_n(trips[i].trip, curr_inst[i]); if (min_inst->t > inst->t) { + free(min_inst); min_inst = inst; min_trip = i; } + else + free(inst); } /* Write line in the CSV file */ char *date_str = pg_date_out(trips[min_trip].day); - char *geom_str = geo_as_ewkt((GSERIALIZED *)&min_inst->value, 6); + char *geom_str = geo_as_ewkt((GSERIALIZED *) &min_inst->value, 6); char *time_str = pg_timestamptz_out(min_inst->t); fprintf(file,"%d,%d,%s,%d,%s,%s\n", trips[min_trip].vehid, trips[min_trip].vehid, date_str, trips[min_trip].seq, geom_str, time_str); - free(date_str); free(geom_str); free(time_str); + free(date_str); free(geom_str); free(time_str); free(min_inst); records_out++; /* Advance the current instant of the trip */ diff --git a/meos/src/general/temporal_modif.c b/meos/src/general/temporal_modif.c index cc156fa144..89ccd58e60 100644 --- a/meos/src/general/temporal_modif.c +++ b/meos/src/general/temporal_modif.c @@ -1595,7 +1595,7 @@ tsequence_append_tinstant(TSequence *seq, const TInstant *inst, double maxdist, Interval *duration = minus_timestamptz_timestamptz(inst->t, last->t); if (pg_interval_cmp(duration, maxt) > 0) split = true; - // CANNOT pfree(duration); + pfree(duration); } /* If split => result is a sequence set */ if (split) diff --git a/meos/src/general/tsequenceset.c b/meos/src/general/tsequenceset.c index 8d19251117..125ed7d353 100644 --- a/meos/src/general/tsequenceset.c +++ b/meos/src/general/tsequenceset.c @@ -486,7 +486,7 @@ ensure_valid_tinstarr_gaps(const TInstant **instants, int count, bool merge, instants[i - 1]->t); if (pg_interval_cmp(duration, maxt) > 0) split = true; - // CANNOT pfree(duration); + pfree(duration); } if (split) result[k++] = i; @@ -961,7 +961,7 @@ tsequenceset_max_val(const TSequenceSet *ss) /** * @ingroup meos_internal_temporal_accessor * @brief Return in the last argument a copy of the n-th value of a temporal - * sequence set + * sequence set * @param[in] ss Temporal sequence set * @param[in] n Number * @param[out] result Value diff --git a/meos/src/point/pgis_types.c b/meos/src/point/pgis_types.c index dbc4f1d4e6..d9a2c75d74 100644 --- a/meos/src/point/pgis_types.c +++ b/meos/src/point/pgis_types.c @@ -1831,7 +1831,9 @@ geo_as_text(const GSERIALIZED *gs, int precision) return NULL; LWGEOM *geom = lwgeom_from_gserialized(gs); - return lwgeom_to_wkt(geom, WKT_ISO, precision, NULL); + char *result = lwgeom_to_wkt(geom, WKT_ISO, precision, NULL); + lwgeom_free(geom); + return result; } /** @@ -1852,7 +1854,9 @@ geo_as_ewkt(const GSERIALIZED *gs, int precision) return NULL; LWGEOM *geom = lwgeom_from_gserialized(gs); - return lwgeom_to_wkt(geom, WKT_EXTENDED, precision, NULL); + char *result = lwgeom_to_wkt(geom, WKT_EXTENDED, precision, NULL); + lwgeom_free(geom); + return result; } /** diff --git a/meos/src/point/tpoint_spatialfuncs.c b/meos/src/point/tpoint_spatialfuncs.c index 857ef6084e..a1ef7c9487 100644 --- a/meos/src/point/tpoint_spatialfuncs.c +++ b/meos/src/point/tpoint_spatialfuncs.c @@ -1176,7 +1176,7 @@ geopoint_make(double x, double y, double z, bool hasz, bool geodetic, lwpoint_make3dz(srid, x, y, z) : lwpoint_make2d(srid, x, y); FLAGS_SET_GEODETIC(point->flags, geodetic); GSERIALIZED *result = geo_serialize((LWGEOM *) point); - // We CANNOT lwpoint_free(point); + lwpoint_free(point); return result; }