00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _MW_UTIL_H
00022 #define _MW_UTIL_H
00023
00024
00025 #include <glib.h>
00026 #include <glib/ghash.h>
00027 #include <glib/glist.h>
00028
00029
00030 #define map_guint_new() \
00031 g_hash_table_new(g_direct_hash, g_direct_equal)
00032
00033
00034 #define map_guint_new_full(valfree) \
00035 g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (valfree))
00036
00037
00038 #define map_guint_insert(ht, key, val) \
00039 g_hash_table_insert((ht), GUINT_TO_POINTER((guint)(key)), (val))
00040
00041
00042 #define map_guint_replace(ht, key, val) \
00043 g_hash_table_replace((ht), GUINT_TO_POINTER((guint)(key)), (val))
00044
00045
00046 #define map_guint_lookup(ht, key) \
00047 g_hash_table_lookup((ht), GUINT_TO_POINTER((guint)(key)))
00048
00049
00050 #define map_guint_remove(ht, key) \
00051 g_hash_table_remove((ht), GUINT_TO_POINTER((guint)(key)))
00052
00053
00054 #define map_guint_steal(ht, key) \
00055 g_hash_table_steal((ht), GUINT_TO_POINTER((guint)(key)))
00056
00057
00058 GList *map_collect_keys(GHashTable *ht);
00059
00060
00061 GList *map_collect_values(GHashTable *ht);
00062
00063
00064 struct mw_datum {
00065 gpointer data;
00066 GDestroyNotify clear;
00067 };
00068
00069
00070 struct mw_datum *mw_datum_new(gpointer data, GDestroyNotify clear);
00071
00072
00073 void mw_datum_set(struct mw_datum *d, gpointer data, GDestroyNotify clear);
00074
00075
00076 gpointer mw_datum_get(struct mw_datum *d);
00077
00078
00079 void mw_datum_clear(struct mw_datum *d);
00080
00081
00082 void mw_datum_free(struct mw_datum *d);
00083
00084
00085 #endif