diff options
author | jaortega <jaortega> | 2000-12-07 23:14:07 +0000 |
---|---|---|
committer | jaortega <jaortega> | 2000-12-07 23:14:07 +0000 |
commit | d0dba18550f315279d65e5b4a2fc7cbd20a98b4a (patch) | |
tree | 451731a3d19f5a38d525e3a3f24ac832645f700b /mixlib | |
parent | e1f601936aa5761ee7d33583cc298bca6793ce37 (diff) | |
download | mdk-d0dba18550f315279d65e5b4a2fc7cbd20a98b4a.tar.gz mdk-d0dba18550f315279d65e5b4a2fc7cbd20a98b4a.tar.bz2 |
(mix_symbol_table_{merge,substract}_table) new functions
Diffstat (limited to 'mixlib')
-rw-r--r-- | mixlib/mix_symbol_table.c | 42 | ||||
-rw-r--r-- | mixlib/mix_symbol_table.h | 9 |
2 files changed, 51 insertions, 0 deletions
diff --git a/mixlib/mix_symbol_table.c b/mixlib/mix_symbol_table.c index 1045886..d59c396 100644 --- a/mixlib/mix_symbol_table.c +++ b/mixlib/mix_symbol_table.c @@ -64,6 +64,48 @@ mix_symbol_table_delete(mix_symbol_table_t *table) g_hash_table_destroy(table); } +/* add/remove symbols from other table */ +static void +add_symbol_(gpointer symbol, gpointer value, gpointer target) +{ + mix_symbol_table_t *t = (mix_symbol_table_t *)target; + gchar *s = (gchar *)symbol; + mix_word_t v = mix_word_new(GPOINTER_TO_UINT(value)); + mix_symbol_table_insert (t, s, v); +} + +static void +remove_symbol_(gpointer symbol, gpointer value, gpointer target) +{ + mix_symbol_table_t *t = (mix_symbol_table_t *)target; + gchar *s = (gchar *)symbol; + mix_symbol_table_remove (t, s); +} + +gboolean +mix_symbol_table_merge_table (mix_symbol_table_t *table, + mix_symbol_table_t *from) +{ + g_return_val_if_fail (table != NULL, FALSE); + if (from != NULL) + { + mix_symbol_table_foreach (from, add_symbol_, table); + } + return TRUE; +} + +gboolean +mix_symbol_table_substract_table (mix_symbol_table_t *table, + mix_symbol_table_t *other) +{ + g_return_val_if_fail (table != NULL, FALSE); + if (other != NULL) + { + mix_symbol_table_foreach (other, remove_symbol_, table); + } + return TRUE; +} + /* Add/remove symbols one by one */ gint diff --git a/mixlib/mix_symbol_table.h b/mixlib/mix_symbol_table.h index da9046f..db48ffd 100644 --- a/mixlib/mix_symbol_table.h +++ b/mixlib/mix_symbol_table.h @@ -47,6 +47,15 @@ mix_symbol_table_new_from_file(FILE *file); extern void mix_symbol_table_delete(mix_symbol_table_t *table); +/* add/remove symbols from other table */ +extern gboolean +mix_symbol_table_merge_table (mix_symbol_table_t *table, + mix_symbol_table_t *from); + +extern gboolean +mix_symbol_table_substract_table (mix_symbol_table_t *table, + mix_symbol_table_t *other); + /* Add/remove symbols one by one */ /* possible outcomes: */ enum { |