1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Hash functions for file-related triples: name, device, inode.
4 Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 /* written by Jim Meyering */
23 #include "hash-triple.h"
30 #include "same-inode.h"
32 #define STREQ(a, b) (strcmp (a, b) == 0)
34 /* Hash an F_triple, and *do* consider the file name. */
36 triple_hash (void const *x, size_t table_size)
38 struct F_triple const *p = x;
39 size_t tmp = hash_pjw (p->name, table_size);
41 /* Ignoring the device number here should be fine. */
42 return (tmp ^ p->st_ino) % table_size;
45 /* Hash an F_triple, without considering the file name. */
47 triple_hash_no_name (void const *x, size_t table_size)
49 struct F_triple const *p = x;
51 /* Ignoring the device number here should be fine. */
52 return p->st_ino % table_size;
55 /* Compare two F_triple structs. */
57 triple_compare (void const *x, void const *y)
59 struct F_triple const *a = x;
60 struct F_triple const *b = y;
61 return (SAME_INODE (*a, *b) && same_name (a->name, b->name)) ? true : false;
65 triple_compare_ino_str (void const *x, void const *y)
67 struct F_triple const *a = x;
68 struct F_triple const *b = y;
69 return (SAME_INODE (*a, *b) && STREQ (a->name, b->name)) ? true : false;
72 /* Free an F_triple. */
76 struct F_triple *a = x;