chiark / gitweb /
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)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:54:00 +0000 (07:54 +0200)
commit743ac495b83a83e7336f55321d38a4ebe7389e58
tree1b07c10fb3fd417601406084d5dacc6b3f7b476a
parent0c8cd4e223e968d446136379f6563d1a0aa82956
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.

(cherry picked from commit 46e16b347f83d809ed3d34f26286f580dfd086ce)
src/basic/hash-funcs.c
src/basic/hash-funcs.h
src/test/test-hashmap.c