mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-02-23 10:30:16 +00:00
Fix more (small) memory leaks
This commit is contained in:
parent
7df269219c
commit
b292b66a7c
@ -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) {
|
||||
|
@ -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) {
|
||||
|
14
pool.c
14
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;
|
||||
|
1
pool.h
1
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user