1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Specialized functions to manipulate a set of files.
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 */
24 #include "hash-triple.h"
27 /* Record file, FILE, and dev/ino from *STATS, in the hash table, HT.
28 If HT is NULL, return immediately.
29 If memory allocation fails, exit immediately. */
31 record_file (Hash_table *ht, char const *file, struct stat const *stats)
38 ent = xmalloc (sizeof *ent);
39 ent->name = xstrdup (file);
40 ent->st_ino = stats->st_ino;
41 ent->st_dev = stats->st_dev;
44 struct F_triple *ent_from_table = hash_insert (ht, ent);
45 if (ent_from_table == NULL)
47 /* Insertion failed due to lack of memory. */
51 if (ent_from_table != ent)
53 /* There was alread a matching entry in the table, so ENT was
54 not inserted. Free it. */
60 /* Return true if there is an entry in hash table, HT,
61 for the file described by FILE and STATS. */
63 seen_file (Hash_table const *ht, char const *file,
64 struct stat const *stats)
66 struct F_triple new_ent;
71 new_ent.name = (char *) file;
72 new_ent.st_ino = stats->st_ino;
73 new_ent.st_dev = stats->st_dev;
75 return !!hash_lookup (ht, &new_ent);