]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/basic/hash-funcs.h
hash-func: add generic hash_ops implementation for hashing paths
authorLennart Poettering <lennart@poettering.net>
Thu, 8 Feb 2018 17:31:15 +0000 (18:31 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 12 Feb 2018 10:07:55 +0000 (11:07 +0100)
commit46e16b347f83d809ed3d34f26286f580dfd086ce
tree80a195b60a719a465639f8fddb5b68518588416f
parent9bac7d423f1d39737e2b7bc35c484ed0d79de73d
hash-func: add generic hash_ops implementation for hashing paths

This is similar to string_hash_ops but operates one file system paths
specifically. It will ensure that "/foo//bar" and "///foo/bar" are
considered to be the same path for hashmap purposes.

This makes use of the existing path_compare() API, and adds a matching
hashing function for it.

Note that relative and absolute paths will hash to different values,
however whether the path is suffixed with a slash or not is not
detected. This matches the existing path_compare() behaviour, and
follows the logic that on Linux there can't be two different objects at
path /foo/bar and /foo/bar/ either.
src/basic/hash-funcs.c
src/basic/hash-funcs.h
src/test/test-hashmap.c