diff options
author | axel <axel@liljencrantz.se> | 2006-06-16 02:03:27 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2006-06-16 02:03:27 +1000 |
commit | d2869d51405754594685514f205566bfef55f28b (patch) | |
tree | f0cef052d5ff977bfe7194dbf7e9669fc554b664 | |
parent | 587e91d0c1173d91ba1256d3fb116d42d660e497 (diff) |
Remove tiny and unlikely memory leak
darcs-hash:20060615160327-ac50b-01b0514c922104a7d36e3a9a0426bb3a671581b2.gz
-rw-r--r-- | history.c | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -91,7 +91,7 @@ static hash_table_t history_table; /** Flag, set to 1 once the history file has been loaded */ -static int is_loaded; +static int is_loaded=0; /** Load history from file @@ -202,7 +202,7 @@ static void history_to_hash() { history_data *d; - if( !history_last ) + if( !mode_name ) return; @@ -229,12 +229,22 @@ void history_set_mode( wchar_t *name ) if( mode_name ) { + /* + Move the current history to the hashtable + */ history_to_hash(); } + + /* + See if the new history already exists + */ curr = (history_data *)hash_get( &history_table, name ); if( curr ) { + /* + Yes. Restore it. + */ mode_name = (wchar_t *)hash_get_key( &history_table, name ); history_current = history_last = curr->last; @@ -244,6 +254,9 @@ void history_set_mode( wchar_t *name ) } else { + /* + Nope. Create a new history list. + */ history_count=0; history_last = history_current = last_loaded=0; mode_name = wcsdup( name ); @@ -370,7 +383,7 @@ static void history_destroy_mode( void *name, void *link ) past_end=1; // fwprintf( stderr, L"Destroy history mode \'%ls\'\n", mode_name ); - + if( history_last ) { history_save(); @@ -389,11 +402,12 @@ static void history_destroy_mode( void *name, void *link ) void history_destroy() { + /** Make sure current mode is in table */ history_to_hash(); - + /** Save all modes in table */ |