@@ -81,7 +81,7 @@ middle_pgsql_t::table_desc::table_desc(const char *name_,
81
81
array_indexes(array_indexes_),
82
82
copyMode(0 ),
83
83
transactionMode(0 ),
84
- sql_conn(NULL )
84
+ sql_conn(nullptr )
85
85
{}
86
86
87
87
#define HELPER_STATE_UNINITIALIZED -1
@@ -169,7 +169,7 @@ inline char *escape_tag( char *ptr, const std::string &in, bool escape )
169
169
return ptr;
170
170
}
171
171
172
- // escape means we return '\N' for copy mode, otherwise we return just NULL */
172
+ // escape means we return '\N' for copy mode, otherwise we return just nullptr */
173
173
const char *pgsql_store_tags (const taglist_t &tags, bool escape)
174
174
{
175
175
static char *buffer;
@@ -181,7 +181,7 @@ const char *pgsql_store_tags(const taglist_t &tags, bool escape)
181
181
if ( escape )
182
182
return " \\ N" ;
183
183
else
184
- return NULL ;
184
+ return nullptr ;
185
185
}
186
186
187
187
if ( buflen <= countlist * 24 ) // LE so 0 always matches */
@@ -294,7 +294,7 @@ int pgsql_endCopy(middle_pgsql_t::table_desc *table)
294
294
// Terminate any pending COPY */
295
295
if (table->copyMode ) {
296
296
PGconn *sql_conn = table->sql_conn ;
297
- int stop = PQputCopyEnd (sql_conn, NULL );
297
+ int stop = PQputCopyEnd (sql_conn, nullptr );
298
298
if (stop != 1 ) {
299
299
fprintf (stderr, " COPY_END for %s failed: %s\n " , table->copy , PQerrorMessage (sql_conn));
300
300
util::exit_nicely ();
@@ -364,7 +364,7 @@ size_t middle_pgsql_t::local_nodes_get_list(nodelist_t &out, const idlist_t nds)
364
364
char tmp[16 ];
365
365
366
366
char *tmp2 = (char *)malloc (sizeof (char ) * nds.size () * 16 );
367
- if (tmp2 == NULL ) return 0 ; // failed to allocate memory, return */
367
+ if (tmp2 == nullptr ) return 0 ; // failed to allocate memory, return */
368
368
369
369
370
370
// create a list of ids in tmp2 to query the database */
@@ -405,17 +405,17 @@ size_t middle_pgsql_t::local_nodes_get_list(nodelist_t &out, const idlist_t nds)
405
405
boost::unordered_map<osmid_t , osmNode> pg_nodes (countPG);
406
406
407
407
for (int i = 0 ; i < countPG; i++) {
408
- osmid_t id = strtoosmid (PQgetvalue (res, i, 0 ), NULL , 10 );
408
+ osmid_t id = strtoosmid (PQgetvalue (res, i, 0 ), nullptr , 10 );
409
409
osmNode node;
410
410
#ifdef FIXED_POINT
411
- ramNode n ((int ) strtol (PQgetvalue (res, i, 2 ), NULL , 10 ),
412
- (int ) strtol (PQgetvalue (res, i, 1 ), NULL , 10 ));
411
+ ramNode n ((int ) strtol (PQgetvalue (res, i, 2 ), nullptr , 10 ),
412
+ (int ) strtol (PQgetvalue (res, i, 1 ), nullptr , 10 ));
413
413
414
414
node.lat = n.lat ();
415
415
node.lon = n.lon ();
416
416
#else
417
- node.lat = strtod (PQgetvalue (res, i, 1 ), NULL );
418
- node.lon = strtod (PQgetvalue (res, i, 2 ), NULL );
417
+ node.lat = strtod (PQgetvalue (res, i, 1 ), nullptr );
418
+ node.lon = strtod (PQgetvalue (res, i, 2 ), nullptr );
419
419
#endif
420
420
pg_nodes.emplace (id, node);
421
421
}
@@ -568,7 +568,7 @@ bool middle_pgsql_t::ways_get(osmid_t id, taglist_t &tags, nodelist_t &nodes) co
568
568
569
569
pgsql_parse_tags ( PQgetvalue (res, 0 , 1 ), tags );
570
570
571
- size_t num_nodes = strtoul (PQgetvalue (res, 0 , 2 ), NULL , 10 );
571
+ size_t num_nodes = strtoul (PQgetvalue (res, 0 , 2 ), nullptr , 10 );
572
572
idlist_t list;
573
573
pgsql_parse_nodes ( PQgetvalue (res, 0 , 0 ), list);
574
574
if (num_nodes != list.size ()) {
@@ -592,7 +592,7 @@ size_t middle_pgsql_t::ways_get_list(const idlist_t &ids, idlist_t &way_ids,
592
592
char const *paramValues[1 ];
593
593
594
594
tmp2 = (char *)malloc (sizeof (char )*ids.size ()*16 );
595
- if (tmp2 == NULL ) return 0 ; // failed to allocate memory, return */
595
+ if (tmp2 == nullptr ) return 0 ; // failed to allocate memory, return */
596
596
597
597
// create a list of ids in tmp2 to query the database */
598
598
sprintf (tmp2, " {" );
@@ -613,7 +613,7 @@ size_t middle_pgsql_t::ways_get_list(const idlist_t &ids, idlist_t &way_ids,
613
613
idlist_t wayidspg;
614
614
615
615
for (int i = 0 ; i < countPG; i++) {
616
- wayidspg.push_back (strtoosmid (PQgetvalue (res, i, 0 ), NULL , 10 ));
616
+ wayidspg.push_back (strtoosmid (PQgetvalue (res, i, 0 ), nullptr , 10 ));
617
617
}
618
618
619
619
@@ -626,7 +626,7 @@ size_t middle_pgsql_t::ways_get_list(const idlist_t &ids, idlist_t &way_ids,
626
626
tags.push_back (taglist_t ());
627
627
pgsql_parse_tags (PQgetvalue (res, j, 2 ), tags.back ());
628
628
629
- size_t num_nodes = strtoul (PQgetvalue (res, j, 3 ), NULL , 10 );
629
+ size_t num_nodes = strtoul (PQgetvalue (res, j, 3 ), nullptr , 10 );
630
630
idlist_t list;
631
631
pgsql_parse_nodes ( PQgetvalue (res, j, 1 ), list);
632
632
if (num_nodes != list.size ()) {
@@ -798,7 +798,7 @@ bool middle_pgsql_t::relations_get(osmid_t id, memberlist_t &members, taglist_t
798
798
pgsql_parse_tags (PQgetvalue (res, 0 , 1 ), tags);
799
799
pgsql_parse_tags (PQgetvalue (res, 0 , 0 ), member_temp);
800
800
801
- if (member_temp.size () != strtoul (PQgetvalue (res, 0 , 2 ), NULL , 10 )) {
801
+ if (member_temp.size () != strtoul (PQgetvalue (res, 0 , 2 ), nullptr , 10 )) {
802
802
fprintf (stderr, " Unexpected member_count reading relation %" PRIdOSMID " \n " , id);
803
803
util::exit_nicely ();
804
804
}
@@ -809,7 +809,7 @@ bool middle_pgsql_t::relations_get(osmid_t id, memberlist_t &members, taglist_t
809
809
char tag = it->key [0 ];
810
810
OsmType type = (tag == ' n' )?OSMTYPE_NODE:(tag == ' w' )?OSMTYPE_WAY:(tag == ' r' )?OSMTYPE_RELATION:((OsmType)-1 );
811
811
members.push_back (member (type,
812
- strtoosmid (it->key .c_str ()+1 , NULL , 10 ),
812
+ strtoosmid (it->key .c_str ()+1 , nullptr , 10 ),
813
813
it->value ));
814
814
}
815
815
return true ;
@@ -895,7 +895,7 @@ idlist_t middle_pgsql_t::relations_using_way(osmid_t way_id) const
895
895
const int ntuples = PQntuples (result);
896
896
idlist_t rel_ids (ntuples);
897
897
for (int i = 0 ; i < ntuples; ++i) {
898
- rel_ids[i] = strtoosmid (PQgetvalue (result, i, 0 ), NULL , 10 );
898
+ rel_ids[i] = strtoosmid (PQgetvalue (result, i, 0 ), nullptr , 10 );
899
899
}
900
900
PQclear (result);
901
901
@@ -954,10 +954,12 @@ static void set_prefix_and_tbls(const struct options_t *options, const char **st
954
954
char buffer[1024 ];
955
955
const char *source;
956
956
char *dest;
957
- char *openbrace = NULL ;
957
+ char *openbrace = nullptr ;
958
958
int copied = 0 ;
959
959
960
- if (*string == NULL ) return ;
960
+ if (*string == nullptr ) {
961
+ return ;
962
+ }
961
963
source = *string;
962
964
dest = buffer;
963
965
@@ -1056,7 +1058,7 @@ void middle_pgsql_t::start(const options_t *out_options_)
1056
1058
// and pass that via the constructor to middle_t, so that middle_t
1057
1059
// itself doesn't need to know about details of the output.
1058
1060
if (out_options->output_backend == " gazetteer" ) {
1059
- way_table->array_indexes = NULL ;
1061
+ way_table->array_indexes = nullptr ;
1060
1062
mark_pending = false ;
1061
1063
}
1062
1064
@@ -1123,7 +1125,7 @@ void middle_pgsql_t::start(const options_t *out_options_)
1123
1125
snprintf (sql, 2047 , " SELECT id FROM %s LIMIT 1" , tables[t_node].name );
1124
1126
res = PQexec (sql_conn, sql );
1125
1127
free (sql);
1126
- sql = NULL ;
1128
+ sql = nullptr ;
1127
1129
if (PQresultStatus (res) == PGRES_TUPLES_OK && PQntuples (res) == 1 )
1128
1130
{
1129
1131
int size = PQfsize (res, 0 );
@@ -1215,10 +1217,10 @@ void *middle_pgsql_t::pgsql_stop_one(void *arg)
1215
1217
}
1216
1218
1217
1219
PQfinish (sql_conn);
1218
- table->sql_conn = NULL ;
1220
+ table->sql_conn = nullptr ;
1219
1221
time (&end);
1220
1222
fprintf (stderr, " Stopped table: %s in %is\n " , table->name , (int )(end - start));
1221
- return NULL ;
1223
+ return nullptr ;
1222
1224
}
1223
1225
1224
1226
namespace {
@@ -1253,15 +1255,15 @@ void middle_pgsql_t::stop(void)
1253
1255
}
1254
1256
1255
1257
for (i=0 ; i<num_tables; i++) {
1256
- int ret = pthread_create (&threads[i], NULL , pthread_middle_pgsql_stop_one, &thunks[i]);
1258
+ int ret = pthread_create (&threads[i], nullptr , pthread_middle_pgsql_stop_one, &thunks[i]);
1257
1259
if (ret) {
1258
1260
fprintf (stderr, " pthread_create() returned an error (%d)" , ret);
1259
1261
util::exit_nicely ();
1260
1262
}
1261
1263
}
1262
1264
1263
1265
for (i=0 ; i<num_tables; i++) {
1264
- int ret = pthread_join (threads[i], NULL );
1266
+ int ret = pthread_join (threads[i], nullptr );
1265
1267
if (ret) {
1266
1268
fprintf (stderr, " pthread_join() returned an error (%d)" , ret);
1267
1269
util::exit_nicely ();
@@ -1274,7 +1276,7 @@ void middle_pgsql_t::stop(void)
1274
1276
}
1275
1277
1276
1278
middle_pgsql_t ::middle_pgsql_t ()
1277
- : tables(), num_tables(0 ), node_table(NULL ), way_table(NULL ), rel_table(NULL ),
1279
+ : tables(), num_tables(0 ), node_table(nullptr ), way_table(nullptr ), rel_table(nullptr ),
1278
1280
append (false ), mark_pending(true ), cache(), persistent_cache(), build_indexes(0 )
1279
1281
{
1280
1282
/* table = t_node,*/
@@ -1283,17 +1285,17 @@ middle_pgsql_t::middle_pgsql_t()
1283
1285
/* start*/ " BEGIN;\n " ,
1284
1286
#ifdef FIXED_POINT
1285
1287
/* create*/ " CREATE %m TABLE %p_nodes (id " POSTGRES_OSMID_TYPE " PRIMARY KEY {USING INDEX TABLESPACE %i}, lat int4 not null, lon int4 not null, tags text[]) {TABLESPACE %t};\n " ,
1286
- /* create_index*/ NULL ,
1288
+ /* create_index*/ nullptr ,
1287
1289
/* prepare*/ " PREPARE insert_node (" POSTGRES_OSMID_TYPE " , int4, int4, text[]) AS INSERT INTO %p_nodes VALUES ($1,$2,$3,$4);\n "
1288
1290
#else
1289
1291
/* create*/ " CREATE %m TABLE %p_nodes (id " POSTGRES_OSMID_TYPE " PRIMARY KEY {USING INDEX TABLESPACE %i}, lat double precision not null, lon double precision not null, tags text[]) {TABLESPACE %t};\n " ,
1290
- /* create_index*/ NULL ,
1292
+ /* create_index*/ nullptr ,
1291
1293
/* prepare*/ " PREPARE insert_node (" POSTGRES_OSMID_TYPE " , double precision, double precision, text[]) AS INSERT INTO %p_nodes VALUES ($1,$2,$3,$4);\n "
1292
1294
#endif
1293
1295
" PREPARE get_node (" POSTGRES_OSMID_TYPE " ) AS SELECT lat,lon,tags FROM %p_nodes WHERE id = $1 LIMIT 1;\n "
1294
1296
" PREPARE get_node_list(" POSTGRES_OSMID_TYPE " []) AS SELECT id, lat, lon FROM %p_nodes WHERE id = ANY($1::" POSTGRES_OSMID_TYPE " []);\n "
1295
1297
" PREPARE delete_node (" POSTGRES_OSMID_TYPE " ) AS DELETE FROM %p_nodes WHERE id = $1;\n " ,
1296
- /* prepare_intarray*/ NULL ,
1298
+ /* prepare_intarray*/ nullptr ,
1297
1299
/* copy*/ " COPY %p_nodes FROM STDIN;\n " ,
1298
1300
/* analyze*/ " ANALYZE %p_nodes;\n " ,
1299
1301
/* stop*/ " COMMIT;\n "
@@ -1303,7 +1305,7 @@ middle_pgsql_t::middle_pgsql_t()
1303
1305
/* name*/ " %p_ways" ,
1304
1306
/* start*/ " BEGIN;\n " ,
1305
1307
/* create*/ " CREATE %m TABLE %p_ways (id " POSTGRES_OSMID_TYPE " PRIMARY KEY {USING INDEX TABLESPACE %i}, nodes " POSTGRES_OSMID_TYPE " [] not null, tags text[]) {TABLESPACE %t};\n " ,
1306
- /* create_index*/ NULL ,
1308
+ /* create_index*/ nullptr ,
1307
1309
/* prepare*/ " PREPARE insert_way (" POSTGRES_OSMID_TYPE " , " POSTGRES_OSMID_TYPE " [], text[]) AS INSERT INTO %p_ways VALUES ($1,$2,$3);\n "
1308
1310
" PREPARE get_way (" POSTGRES_OSMID_TYPE " ) AS SELECT nodes, tags, array_upper(nodes,1) FROM %p_ways WHERE id = $1;\n "
1309
1311
" PREPARE get_way_list (" POSTGRES_OSMID_TYPE " []) AS SELECT id, nodes, tags, array_upper(nodes,1) FROM %p_ways WHERE id = ANY($1::" POSTGRES_OSMID_TYPE " []);\n "
@@ -1322,7 +1324,7 @@ middle_pgsql_t::middle_pgsql_t()
1322
1324
/* name*/ " %p_rels" ,
1323
1325
/* start*/ " BEGIN;\n " ,
1324
1326
/* create*/ " CREATE %m TABLE %p_rels(id " POSTGRES_OSMID_TYPE " PRIMARY KEY {USING INDEX TABLESPACE %i}, way_off int2, rel_off int2, parts " POSTGRES_OSMID_TYPE " [], members text[], tags text[]) {TABLESPACE %t};\n " ,
1325
- /* create_index*/ NULL ,
1327
+ /* create_index*/ nullptr ,
1326
1328
/* prepare*/ " PREPARE insert_rel (" POSTGRES_OSMID_TYPE " , int2, int2, " POSTGRES_OSMID_TYPE " [], text[], text[]) AS INSERT INTO %p_rels VALUES ($1,$2,$3,$4,$5,$6);\n "
1327
1329
" PREPARE get_rel (" POSTGRES_OSMID_TYPE " ) AS SELECT members, tags, array_upper(members,1)/2 FROM %p_rels WHERE id = $1;\n "
1328
1330
" PREPARE delete_rel(" POSTGRES_OSMID_TYPE " ) AS DELETE FROM %p_rels WHERE id = $1;\n " ,
0 commit comments