summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Garrett <jeff@jgarrett.org>2007-11-21 00:17:47 -0600
committerJeff Garrett <jeff@jgarrett.org>2007-11-21 00:17:47 -0600
commit5ed820011bcafef38d412bc1bfffd4b4be11ec8b (patch)
tree1f2e824b72f0f774baae88db5d5adf7a75a101ad
parentb217747c98bdb3d0f66dfc83ddad84cb5f3162e5 (diff)
Initialize road suffix list lazily
-rw-r--r--src/main.c3
-rw-r--r--src/road.c8
-rw-r--r--src/road.h2
3 files changed, 7 insertions, 6 deletions
diff --git a/src/main.c b/src/main.c
index 68f69b1..1108beb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -148,9 +148,6 @@ gboolean main_init(void)
g_free(pszApplicationDir);
#endif
- g_print("initializing road\n");
- road_init();
-
g_print("initializing map styles\n");
map_style_init();
diff --git a/src/road.c b/src/road.c
index edeca98..8eb0497 100644
--- a/src/road.c
+++ b/src/road.c
@@ -43,7 +43,7 @@ struct {
GArray* pRoadNameSuffixArray; // an array of null-terminated vectors (an array of gchar* with the last being NULL)
} g_Road = {0};
-void road_init()
+static void road_init()
{
gchar* pszPath = g_strdup_printf(PACKAGE_SOURCE_DIR"/data/%s", ROAD_SUFFIX_LIST_FILE_NAME);
if(util_load_array_of_string_vectors(pszPath, &(g_Road.pRoadNameSuffixArray), ROAD_SUFFIX_LIST_MIN_WORDS) == FALSE) {
@@ -62,6 +62,9 @@ void road_init()
const gchar* road_suffix_itoa(gint nSuffixID, ESuffixLength eSuffixLength)
{
+ if (!g_Road)
+ road_init();
+
if(nSuffixID < g_Road.pRoadNameSuffixArray->len) {
//g_debug("looking up suffixID %d", nSuffixID);
gchar** apszWords = g_array_index(g_Road.pRoadNameSuffixArray, gchar**, nSuffixID);
@@ -75,6 +78,9 @@ const gchar* road_suffix_itoa(gint nSuffixID, ESuffixLength eSuffixLength)
gboolean road_suffix_atoi(const gchar* pszSuffix, gint* pReturnSuffixID)
{
+ if (!g_Road)
+ road_init();
+
g_assert(pszSuffix != NULL);
g_assert(pReturnSuffixID != NULL);
diff --git a/src/road.h b/src/road.h
index cccab28..12262c8 100644
--- a/src/road.h
+++ b/src/road.h
@@ -26,8 +26,6 @@
#include "map.h"
-void road_init();
-
typedef struct {
GArray* pMapPointsArray;