aboutsummaryrefslogtreecommitdiffhomepage
path: root/parse_util.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-02-10 01:50:20 +1000
committerGravatar axel <axel@liljencrantz.se>2006-02-10 01:50:20 +1000
commitd1c9bca2e9f0eaac2fb8e00e5ed07e8e2906bb02 (patch)
tree9de2b4fd732398afaebd00c732d8fe41762ac322 /parse_util.c
parent49973b85dac4baf843b95ae22ffaed7f41ae43bc (diff)
Another halloc:ification of fish. Halloc has been extended to allow registering function calls, this has allowed the creation of halloc-handled arraylists, stringbuffers, etc. More job parsing halloc-ification has reduced the error handling code to only a shadow of it's former self
darcs-hash:20060209155020-ac50b-e119c5293ce2368e252cfc01b98ab7c629fdd678.gz
Diffstat (limited to 'parse_util.c')
-rw-r--r--parse_util.c67
1 files changed, 32 insertions, 35 deletions
diff --git a/parse_util.c b/parse_util.c
index e9eb1d03..dbcffdb2 100644
--- a/parse_util.c
+++ b/parse_util.c
@@ -24,6 +24,7 @@
#include "expand.h"
#include "intern.h"
#include "exec.h"
+#include "halloc_util.h"
/**
Set of files which have been autoloaded
@@ -427,6 +428,36 @@ void parse_util_token_extent( const wchar_t *buff,
}
+/**
+ Free hash value, but not hash key
+*/
+static void clear_hash_value( const void *key, const void *data )
+{
+ free( (void *)data );
+}
+
+static void clear_loaded_entry( const void *key, const void *data )
+{
+ hash_table_t *loaded = (hash_table_t *)data;
+ hash_foreach( loaded,
+ &clear_hash_value );
+ hash_destroy( loaded );
+ free( loaded );
+ free( (void *)key );
+}
+
+static void parse_util_destroy()
+{
+ if( all_loaded )
+ {
+ hash_foreach( all_loaded,
+ &clear_loaded_entry );
+
+ hash_destroy( all_loaded );
+ free( all_loaded );
+ all_loaded = 0;
+ }
+}
int parse_util_load( const wchar_t *cmd,
const wchar_t *path_var,
@@ -469,6 +500,7 @@ int parse_util_load( const wchar_t *cmd,
}
hash_init( loaded, &hash_wcs_func, &hash_wcs_cmp );
hash_put( all_loaded, wcsdup(path_var), loaded );
+ halloc_register_function_void( global_context, &parse_util_destroy );
}
/*
@@ -564,38 +596,3 @@ int parse_util_load( const wchar_t *cmd,
return reloaded;
}
-void parse_util_init()
-{
-}
-
-/**
- Free hash value, but not hash key
-*/
-static void clear_hash_value( const void *key, const void *data )
-{
- free( (void *)data );
-}
-
-static void clear_loaded_entry( const void *key, const void *data )
-{
- hash_table_t *loaded = (hash_table_t *)data;
- hash_foreach( loaded,
- &clear_hash_value );
- hash_destroy( loaded );
- free( loaded );
- free( (void *)key );
-}
-
-void parse_util_destroy()
-{
- if( all_loaded )
- {
- hash_foreach( all_loaded,
- &clear_loaded_entry );
-
- hash_destroy( all_loaded );
- free( all_loaded );
- all_loaded = 0;
- }
-}
-