Remove tiny and unlikely memory leak

darcs-hash:20060615160327-ac50b-01b0514c922104a7d36e3a9a0426bb3a671581b2.gz
This commit is contained in:
axel 2006-06-16 02:03:27 +10:00
parent 587e91d0c1
commit d2869d5140

View file

@ -91,7 +91,7 @@ static hash_table_t history_table;
/** /**
Flag, set to 1 once the history file has been loaded Flag, set to 1 once the history file has been loaded
*/ */
static int is_loaded; static int is_loaded=0;
/** /**
Load history from file Load history from file
@ -202,7 +202,7 @@ static void history_to_hash()
{ {
history_data *d; history_data *d;
if( !history_last ) if( !mode_name )
return; return;
@ -229,12 +229,22 @@ void history_set_mode( wchar_t *name )
if( mode_name ) if( mode_name )
{ {
/*
Move the current history to the hashtable
*/
history_to_hash(); history_to_hash();
} }
/*
See if the new history already exists
*/
curr = (history_data *)hash_get( &history_table, curr = (history_data *)hash_get( &history_table,
name ); name );
if( curr ) if( curr )
{ {
/*
Yes. Restore it.
*/
mode_name = (wchar_t *)hash_get_key( &history_table, mode_name = (wchar_t *)hash_get_key( &history_table,
name ); name );
history_current = history_last = curr->last; history_current = history_last = curr->last;
@ -244,6 +254,9 @@ void history_set_mode( wchar_t *name )
} }
else else
{ {
/*
Nope. Create a new history list.
*/
history_count=0; history_count=0;
history_last = history_current = last_loaded=0; history_last = history_current = last_loaded=0;
mode_name = wcsdup( name ); mode_name = wcsdup( name );
@ -389,6 +402,7 @@ static void history_destroy_mode( void *name, void *link )
void history_destroy() void history_destroy()
{ {
/** /**
Make sure current mode is in table Make sure current mode is in table
*/ */