diff options
author | João Valverde <j@v6e.pt> | 2023-04-17 16:39:00 +0100 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2023-04-19 16:16:28 +0100 |
commit | 1ff7b8303781819fdaeb01be4b40ca6aa77d9cc5 (patch) | |
tree | bc792a09c4407243be70b284cb09770e2d54a5bc /epan/ftypes/ftype-string.c | |
parent | 7595af96a08744392b1ff2a866c1d86ef6b7099e (diff) |
ftypes: Add a hash/equal method
Add methods to make fvalues hashable with GHashTable.
Diffstat (limited to 'epan/ftypes/ftype-string.c')
-rw-r--r-- | epan/ftypes/ftype-string.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/epan/ftypes/ftype-string.c b/epan/ftypes/ftype-string.c index 4010eac057..195267f7aa 100644 --- a/epan/ftypes/ftype-string.c +++ b/epan/ftypes/ftype-string.c @@ -112,6 +112,12 @@ val_from_charconst(fvalue_t *fv, unsigned long num, gchar **err_msg) return TRUE; } +static guint +string_hash(const fvalue_t *fv) +{ + return g_str_hash(wmem_strbuf_get_str(fv->value.strbuf)); +} + static gboolean string_is_zero(const fvalue_t *fv) { @@ -203,6 +209,7 @@ ftype_register_string(void) cmp_contains, cmp_matches, + string_hash, /* hash */ string_is_zero, /* is_zero */ NULL, /* is_negative */ len, @@ -238,6 +245,7 @@ ftype_register_string(void) cmp_contains, /* cmp_contains */ cmp_matches, + string_hash, /* hash */ string_is_zero, /* is_zero */ NULL, /* is_negative */ len, @@ -273,6 +281,7 @@ ftype_register_string(void) cmp_contains, /* cmp_contains */ cmp_matches, + string_hash, /* hash */ string_is_zero, /* is_zero */ NULL, /* is_negative */ len, @@ -308,6 +317,7 @@ ftype_register_string(void) cmp_contains, /* cmp_contains */ cmp_matches, + string_hash, /* hash */ string_is_zero, /* is_zero */ NULL, /* is_negative */ len, @@ -343,6 +353,7 @@ ftype_register_string(void) cmp_contains, /* cmp_contains */ cmp_matches, + string_hash, /* hash */ string_is_zero, /* is_zero */ NULL, /* is_negative */ len, |