Commit Graph

3 Commits

Author SHA1 Message Date
Nick Alcock 9658dc3963 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.
2019-07-01 11:05:59 +01:00
Nick Alcock 3e10cffc98 libctf: fix hash removal
We must call htab_remove_elt with an element (in this case, a mocked-up
one with only the key populated, since no reasonable hash function will
need the other fields), not with the key alone.

libctf/
	* ctf-hash.c (ctf_dynhash_remove): Call with a mocked-up element.
2019-07-01 11:05:59 +01:00
Nick Alcock c0754cdd9a libctf: hashing
libctf maintains two distinct hash ADTs, one (ctf_dynhash) for wrapping
dynamically-generated unknown-sized hashes during CTF file construction,
one (ctf_hash) for wrapping unchanging hashes whose size is known at
creation time for reading CTF files that were previously created.

In the binutils implementation, these are both fairly thin wrappers
around libiberty hashtab.

Unusually, this code is not kept synchronized with libdtrace-ctf,
due to its dependence on libiberty hashtab.

libctf/
	* ctf-hash.c: New file.
	* ctf-impl.h: New declarations.
2019-05-28 17:07:29 +01:00