From 0152db4a20ca8f7e59087321fba6c1e2a1baf534 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 7 Nov 2017 15:57:56 -0800 Subject: [PATCH] More initializers --- geobuf.cpp | 18 ++++++++-------- main.cpp | 58 +++++++++++++++++++++++++------------------------- serial.hpp | 4 ++-- tile-join.cpp | 52 ++++++++++++++++++++++---------------------- write_json.cpp | 12 +++++------ 5 files changed, 72 insertions(+), 72 deletions(-) diff --git a/geobuf.cpp b/geobuf.cpp index a48b311..a3e965f 100644 --- a/geobuf.cpp +++ b/geobuf.cpp @@ -22,13 +22,13 @@ #define MULTIPOLYGON 5 struct queued_feature { - protozero::pbf_reader pbf; - size_t dim; - double e; - std::vector *keys; - std::vector *sst; - int layer; - std::string layername; + protozero::pbf_reader pbf{}; + size_t dim = 0; + double e = 0; + std::vector *keys = NULL; + std::vector *sst = NULL; + int layer = 0; + std::string layername = ""; }; static std::vector feature_queue; @@ -196,8 +196,8 @@ drawvec readMultiPolygon(std::vector &coords, std::vector &lengt } struct drawvec_type { - drawvec dv; - int type; + drawvec dv{}; + int type = 0; }; std::vector readGeometry(protozero::pbf_reader &pbf, size_t dim, double e, std::vector &keys) { diff --git a/main.cpp b/main.cpp index eb8d225..1fdbb48 100644 --- a/main.cpp +++ b/main.cpp @@ -71,8 +71,8 @@ int prevent[256]; int additional[256]; struct source { - std::string layer; - std::string file; + std::string layer = ""; + std::string file = ""; }; size_t CPUS; @@ -437,34 +437,34 @@ void do_read_parallel(char *map, long long len, long long initial_offset, const } struct read_parallel_arg { - int fd; - FILE *fp; - long long offset; - long long len; - volatile int *is_parsing; - int separator; + int fd = 0; + FILE *fp = NULL; + long long offset = 0; + long long len = 0; + volatile int *is_parsing = NULL; + int separator = 0; - const char *reading; - std::vector *readers; - volatile long long *progress_seq; - std::set *exclude; - std::set *include; - int exclude_all; - json_object *filter; - int maxzoom; - int basezoom; - int source; - std::vector > *layermaps; - int *initialized; - unsigned *initial_x; - unsigned *initial_y; - std::string layername; - bool uses_gamma; - std::map const *attribute_types; - double *dist_sum; - size_t *dist_count; - bool want_dist; - bool filters; + const char *reading = NULL; + std::vector *readers = NULL; + volatile long long *progress_seq = NULL; + std::set *exclude = NULL; + std::set *include = NULL; + int exclude_all = 0; + json_object *filter = NULL; + int maxzoom = 0; + int basezoom = 0; + int source = 0; + std::vector > *layermaps = NULL; + int *initialized = NULL; + unsigned *initial_x = NULL; + unsigned *initial_y = NULL; + std::string layername = ""; + bool uses_gamma = false; + std::map const *attribute_types = NULL; + double *dist_sum = NULL; + size_t *dist_count = NULL; + bool want_dist = false; + bool filters = false; }; void *run_read_parallel(void *v) { diff --git a/serial.hpp b/serial.hpp index 2269bd8..d72a960 100644 --- a/serial.hpp +++ b/serial.hpp @@ -90,8 +90,8 @@ struct reader { long long file_bbox[4] = {0, 0, 0, 0}; - struct stat geomst; - struct stat metast; + struct stat geomst {}; + struct stat metast {}; char *geom_map = NULL; }; diff --git a/tile-join.cpp b/tile-join.cpp index 83db393..4a9d668 100644 --- a/tile-join.cpp +++ b/tile-join.cpp @@ -322,20 +322,20 @@ double max(double a, double b) { } struct reader { - long long zoom; - long long x; - long long sorty; - long long y; - int pbf_count; - int z_flag; + long long zoom = 0; + long long x = 0; + long long sorty = 0; + long long y = 0; + int pbf_count = 0; + int z_flag = 0; - std::string data; - std::vector pbf_path; - std::vector large_zoom; + std::string data = ""; + std::vector pbf_path{}; + std::vector large_zoom{}; - sqlite3 *db; - sqlite3_stmt *stmt; - struct reader *next; + sqlite3 *db = NULL; + sqlite3_stmt *stmt = NULL; + struct reader *next = NULL; bool operator<(const struct reader &r) const { if (zoom < r.zoom) { @@ -569,10 +569,10 @@ struct zxy { long long x; long long y; - zxy(long long _z, long long _x, long long _y) { - z = _z; - x = _x; - y = _y; + zxy(long long _z, long long _x, long long _y) + : z(_z), + x(_x), + y(_y) { } bool operator<(zxy const &other) const { @@ -599,18 +599,18 @@ struct zxy { }; struct arg { - std::map> inputs; - std::map outputs; + std::map> inputs{}; + std::map outputs{}; - std::map *layermap; + std::map *layermap = NULL; - std::vector *header; - std::map> *mapping; - std::set *exclude; - std::set *keep_layers; - std::set *remove_layers; - int ifmatched; - json_object *filter; + std::vector *header = NULL; + std::map> *mapping = NULL; + std::set *exclude = NULL; + std::set *keep_layers = NULL; + std::set *remove_layers = NULL; + int ifmatched = 0; + json_object *filter = NULL; }; void *join_worker(void *v) { diff --git a/write_json.cpp b/write_json.cpp index f6efb53..eaa198e 100644 --- a/write_json.cpp +++ b/write_json.cpp @@ -16,12 +16,12 @@ struct lonlat { long long x; long long y; - lonlat(int nop, double nlon, double nlat, long long nx, long long ny) { - this->op = nop; - this->lon = nlon; - this->lat = nlat; - this->x = nx; - this->y = ny; + lonlat(int nop, double nlon, double nlat, long long nx, long long ny) + : op(nop), + lon(nlon), + lat(nlat), + x(nx), + y(ny) { } };