1 /* Hash functions for file-related triples: name, device, inode. 2 Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc. 3 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. 8 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. 13 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/>. */ 16 17 /* written by Jim Meyering */ 18 19 #include <config.h> 20 21 /* Specification. */ 22 #include "hash-triple.h" 23 24 #include "same.h" 25 #include "same-inode.h" 26 27 /* Hash an F_triple, without considering the file name. */ 28 size_t 29 triple_hash_no_name (void const *x, size_t table_size) /* */ 30 { 31 struct F_triple const *p = x; 32 33 /* Ignoring the device number here should be fine. */ 34 return p->st_ino % table_size; 35 } 36 37 /* Compare two F_triple structs. */ 38 bool 39 triple_compare (void const *x, void const *y) /* */ 40 { 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; 44 }