From 5ed820011bcafef38d412bc1bfffd4b4be11ec8b Mon Sep 17 00:00:00 2001 From: Jeff Garrett Date: Wed, 21 Nov 2007 00:17:47 -0600 Subject: Initialize road suffix list lazily --- src/main.c | 3 --- src/road.c | 8 +++++++- src/road.h | 2 -- 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; -- cgit v1.2.3