diff --git a/geojson.c b/geojson.c index 675384c..03317e5 100644 --- a/geojson.c +++ b/geojson.c @@ -526,6 +526,8 @@ next_feature: tile2latlon(file_bbox[2], file_bbox[3], 32, &minlat, &maxlon); mbtiles_write_metadata(outdb, fname, layername, minzoom, maxzoom, minlat, minlon, maxlat, maxlon, midlat, midlon, &file_keys); + + pool_free_strings(&file_keys); } int main(int argc, char **argv) { diff --git a/mbtiles.c b/mbtiles.c index 036a748..cc65768 100644 --- a/mbtiles.c +++ b/mbtiles.c @@ -202,6 +202,7 @@ void mbtiles_write_metadata(sqlite3 *outdb, char *fname, char *layername, int mi exit(EXIT_FAILURE); } sqlite3_free(sql); + free(buf); } void mbtiles_close(sqlite3 *outdb, char **argv) { diff --git a/pool.c b/pool.c index 830e9f4..015d93c 100644 --- a/pool.c +++ b/pool.c @@ -84,8 +84,12 @@ struct pool_val *pool_long_long(struct pool *p, long long *s, int type) { return pool1(p, (char *) s, type, llcmp); } -void pool_free(struct pool *p) { +void pool_free1(struct pool *p, void (*func)(void *)) { while (p->head != NULL) { + if (func != NULL) { + func(p->head->s); + } + struct pool_val *next = p->head->next; free(p->head); p->head = next; @@ -96,6 +100,14 @@ void pool_free(struct pool *p) { p->vals = NULL; } +void pool_free(struct pool *p) { + pool_free1(p, NULL); +} + +void pool_free_strings(struct pool *p) { + pool_free1(p, free); +} + void pool_init(struct pool *p, int n) { p->n = n; p->vals = NULL; diff --git a/pool.h b/pool.h index 383b252..07f1491 100644 --- a/pool.h +++ b/pool.h @@ -21,5 +21,6 @@ struct pool { struct pool_val *pool(struct pool *p, char *s, int type); struct pool_val *pool_long_long(struct pool *p, long long *val, int type); void pool_free(struct pool *p); +void pool_free_strings(struct pool *p); void pool_init(struct pool *p, int n); int is_pooled(struct pool *p, char *s, int type);