diff options
author | Jeff Garrett <jeff@jgarrett.org> | 2007-11-21 00:17:47 -0600 |
---|---|---|
committer | Jeff Garrett <jeff@jgarrett.org> | 2007-11-21 00:17:47 -0600 |
commit | 5ed820011bcafef38d412bc1bfffd4b4be11ec8b (patch) | |
tree | 1f2e824b72f0f774baae88db5d5adf7a75a101ad | |
parent | b217747c98bdb3d0f66dfc83ddad84cb5f3162e5 (diff) |
Initialize road suffix list lazily
-rw-r--r-- | src/main.c | 3 | ||||
-rw-r--r-- | src/road.c | 8 | ||||
-rw-r--r-- | src/road.h | 2 |
3 files changed, 7 insertions, 6 deletions
@@ -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(); @@ -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); @@ -26,8 +26,6 @@ #include "map.h" -void road_init(); - typedef struct { GArray* pMapPointsArray; |