1 /* Hash functions for file-related triples: name, device, inode.
2 Copyright (C) 2007, 2009-2020 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* written by Jim Meyering */
22 #include "hash-triple.h"
25 #include "same-inode.h"
27 /* Hash an F_triple, without considering the file name. */
29 triple_hash_no_name (void const *x
, size_t table_size
)
31 struct F_triple
const *p
= x
;
33 /* Ignoring the device number here should be fine. */
34 return p
->st_ino
% table_size
;
37 /* Compare two F_triple structs. */
39 triple_compare (void const *x
, void const *y
)
41 struct F_triple
const *a
= x
;
42 struct F_triple
const *b
= y
;
43 return (SAME_INODE (*a
, *b
) && same_name (a
->name
, b
->name
)) ? true : false;