diff options
author | 2006-08-29 02:27:34 +1000 | |
---|---|---|
committer | 2006-08-29 02:27:34 +1000 | |
commit | 7df536023b264be8bc88251656eb5dc4d789a9f6 (patch) | |
tree | b1dd5191a1350ba3608ef4567ebf4c4179456039 | |
parent | f5f15f9de25d3f38baa38d8bb49a162b3eb1e730 (diff) |
Fix concurrency bug in autoloader causing memory leak
darcs-hash:20060828162734-ac50b-76c88ba8cc164646dcff16cb899633f1e10392e2.gz
-rw-r--r-- | parse_util.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/parse_util.c b/parse_util.c index b5b360f3..6100f3be 100644 --- a/parse_util.c +++ b/parse_util.c @@ -592,7 +592,7 @@ int parse_util_load( const wchar_t *cmd, void (*on_load)(const wchar_t *cmd), int reload ) { - static array_list_t *path_list=0; + array_list_t *path_list=0; autoload_t *loaded; @@ -678,14 +678,11 @@ int parse_util_load( const wchar_t *cmd, } - if( !path_list ) - path_list = al_halloc( global_context); - - al_truncate( path_list, 0 ); + path_list = al_new( global_context); tokenize_variable_array( path_var, path_list ); - c = hash_get_count( &loaded->is_loading ); + c = al_get_count( path_list ); hash_put( &loaded->is_loading, cmd, cmd ); @@ -700,14 +697,16 @@ int parse_util_load( const wchar_t *cmd, */ hash_remove( &loaded->is_loading, cmd, 0, 0 ); + c2 = al_get_count( path_list ); + al_foreach( path_list, &free ); - al_truncate( path_list, 0 ); - + al_destroy( path_list ); + free( path_list ); + /** Make sure we didn't 'drop' something */ - - c2 = hash_get_count( &loaded->is_loading ); + assert( c == c2 ); return res; |