aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-impl.h
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2019-06-27 13:30:22 +0100
committerNick Alcock <nick.alcock@oracle.com>2019-07-01 11:05:59 +0100
commit9658dc39630b8ac4e849fb529a53902da5fc2b1f (patch)
treedd5246f204e11dd0a90c874ec81dc705f23d58db /libctf/ctf-impl.h
parent3e10cffc9872fda4519f76ba487fd108551a179f (diff)
downloadfsf-binutils-gdb-9658dc39630b8ac4e849fb529a53902da5fc2b1f.zip
fsf-binutils-gdb-9658dc39630b8ac4e849fb529a53902da5fc2b1f.tar.gz
fsf-binutils-gdb-9658dc39630b8ac4e849fb529a53902da5fc2b1f.tar.bz2
libctf: add hash traversal helpers
There are two, ctf_dynhash_iter and ctf_dynhash_iter_remove: the latter lets you return a nonzero value to remove the element being iterated over. Used in the next commit. libctf/ * ctf-impl.h (ctf_hash_iter_f): New. (ctf_dynhash_iter): New declaration. (ctf_dynhash_iter_remove): New declaration. * ctf-hash.c (ctf_dynhash_iter): Define. (ctf_dynhash_iter_remove): Likewise. (ctf_hashtab_traverse): New. (ctf_hashtab_traverse_remove): Likewise. (struct ctf_traverse_cb_arg): Likewise. (struct ctf_traverse_remove_cb_arg): Likewise.
Diffstat (limited to 'libctf/ctf-impl.h')
-rw-r--r--libctf/ctf-impl.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/libctf/ctf-impl.h b/libctf/ctf-impl.h
index 44f0493..2601e1b 100644
--- a/libctf/ctf-impl.h
+++ b/libctf/ctf-impl.h
@@ -295,6 +295,9 @@ extern int ctf_hash_eq_string (const void *, const void *);
typedef void (*ctf_hash_free_fun) (void *);
+typedef void (*ctf_hash_iter_f) (void *key, void *value, void *arg);
+typedef int (*ctf_hash_iter_remove_f) (void *key, void *value, void *arg);
+
extern ctf_hash_t *ctf_hash_create (unsigned long, ctf_hash_fun, ctf_hash_eq_fun);
extern int ctf_hash_insert_type (ctf_hash_t *, ctf_file_t *, uint32_t, uint32_t);
extern int ctf_hash_define_type (ctf_hash_t *, ctf_file_t *, uint32_t, uint32_t);
@@ -308,6 +311,9 @@ extern int ctf_dynhash_insert (ctf_dynhash_t *, void *, void *);
extern void ctf_dynhash_remove (ctf_dynhash_t *, const void *);
extern void *ctf_dynhash_lookup (ctf_dynhash_t *, const void *);
extern void ctf_dynhash_destroy (ctf_dynhash_t *);
+extern void ctf_dynhash_iter (ctf_dynhash_t *, ctf_hash_iter_f, void *);
+extern void ctf_dynhash_iter_remove (ctf_dynhash_t *, ctf_hash_iter_remove_f,
+ void *);
#define ctf_list_prev(elem) ((void *)(((ctf_list_t *)(elem))->l_prev))
#define ctf_list_next(elem) ((void *)(((ctf_list_t *)(elem))->l_next))