From: Kaj-Michael Lang Date: Tue, 18 Mar 2008 19:05:02 +0000 (+0200) Subject: Add a bunch of g_return_val_if_fail checks. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7cf980b91800c60e603ca0c4e6c61f6e191fb1f6;p=mapper Add a bunch of g_return_val_if_fail checks. --- diff --git a/src/osm-db.c b/src/osm-db.c index bd9b7b6..1e3a2d9 100644 --- a/src/osm-db.c +++ b/src/osm-db.c @@ -491,6 +491,8 @@ osm_place_get(guint32 id, gint lat, gint lon, osm_place **nr) { osm_place *n; +g_return_val_if_fail(sql.select_place, FALSE); + n=*nr; n=osm_place_cache_lookup(id); if (n) { @@ -541,6 +543,8 @@ osm_find_nearest_place(node_type_t type, gint lat, gint lon, osm_place **nr) gint range; osm_place *n=NULL; +g_return_val_if_fail(sql.select_place_near, FALSE); + switch (type) { case NODE_PLACE_SUBURB: range=95000; @@ -607,6 +611,8 @@ osm_way *w; gulong tms; guint wc=0; +g_return_val_if_fail(sql.select_way2, NULL); + sqlite3_reset(sql.select_way2); sqlite3_clear_bindings(sql.select_way2); @@ -664,6 +670,9 @@ osm_way *w; guint wc=0; sqlite3_stmt *psql=NULL; +g_return_val_if_fail(sql.select_node_next, FALSE); +g_return_val_if_fail(sql.select_node_prev, FALSE); + switch (d) { case OSM_NODE_NEXT: psql=sql.select_node_next; @@ -832,6 +841,8 @@ return cw; osm_way_node * osm_way_get_prev_node(osm_way *w) { +g_return_val_if_fail(sql.select_way_prev_seg, NULL); + sqlite3_reset(sql.select_way_prev_seg); sqlite3_clear_bindings(sql.select_way_prev_seg); @@ -859,6 +870,8 @@ return NULL; osm_way_node * osm_way_get_next_node(osm_way *w) { +g_return_val_if_fail(sql.select_way_next_seg, NULL); + sqlite3_reset(sql.select_way_next_seg); sqlite3_clear_bindings(sql.select_way_next_seg); @@ -889,6 +902,8 @@ osm_way_get_nodes(osm_way *w) if (w->nodes!=NULL) return TRUE; +g_return_val_if_fail(sql.select_way_nodes, FALSE); + sqlite3_reset(sql.select_way_nodes); sqlite3_clear_bindings(sql.select_way_nodes); @@ -917,6 +932,8 @@ return (w->nodes==NULL) ? FALSE : TRUE; gboolean osm_way_get_name(osm_way *w) { +g_return_val_if_fail(sql.select_way_name, FALSE); + sqlite3_reset(sql.select_way_name); sqlite3_clear_bindings(sql.select_way_name); @@ -937,6 +954,8 @@ return FALSE; gboolean osm_way_get_name_nls(osm_way *w) { +g_return_val_if_fail(sql.select_way_name_nls, FALSE); + sqlite3_reset(sql.select_way_name_nls); sqlite3_clear_bindings(sql.select_way_name_nls); @@ -963,6 +982,8 @@ return FALSE; gboolean osm_way_get_ref(osm_way *w) { +g_return_val_if_fail(sql.select_way_ref, FALSE); + sqlite3_reset(sql.select_way_ref); sqlite3_clear_bindings(sql.select_way_ref); @@ -1124,6 +1145,9 @@ guint rows=0; gchar tmp1[16], tmp2[16]; gdouble range=6; +g_return_val_if_fail(sql.select_place_search, FALSE); +g_return_val_if_fail(text, FALSE); + ltext=g_strdup_printf("%s%%", text); if (SQLITE_OK != sqlite3_bind_double(sql.select_place_search, 1, lat) || @@ -1195,6 +1219,9 @@ guint rows=0; gchar tmp1[16], tmp2[16]; gdouble range=6; +g_return_val_if_fail(sql.select_way_name_search, FALSE); +g_return_val_if_fail(text, FALSE); + g_debug("Way Search: [%s] around %.6f %.6f", text, lat, lon); ltext=g_strdup_printf("%s%%", text);