summaryrefslogtreecommitdiff
path: root/src/cp-hash.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-10-07 08:41:03 +0000
committerJim Meyering <jim@meyering.net>2001-10-07 08:41:03 +0000
commit61b95dac6923f9ee9a53f3a42bef8124b932ac06 (patch)
tree176f8890a8931146630de73fa5e235ae74233782 /src/cp-hash.c
parent3cff443b59e8b15a4689dd1bbe890a914b6c2b62 (diff)
downloadcoreutils-61b95dac6923f9ee9a53f3a42bef8124b932ac06.tar.xz
(remember_copied): Make a local copy of the file name.
(src_to_dest_free): New function (to free the above). (hash_init): Register src_to_dest_free.
Diffstat (limited to 'src/cp-hash.c')
-rw-r--r--src/cp-hash.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/cp-hash.c b/src/cp-hash.c
index 10c60bf60..b245994ba 100644
--- a/src/cp-hash.c
+++ b/src/cp-hash.c
@@ -75,6 +75,14 @@ src_to_dest_compare (void const *x, void const *y)
return SAME_INODE (*a, *b) ? true : false;
}
+static void
+src_to_dest_free (void *x)
+{
+ struct Src_to_dest *a = x;
+ free ((char *) (a->name));
+ free (x);
+}
+
/* Add PATH to the list of files that we have created.
Return 1 if we can't stat PATH, otherwise 0. */
@@ -104,7 +112,7 @@ remember_copied (const char *name, ino_t ino, dev_t dev)
struct Src_to_dest *ent_from_table;
ent = (struct Src_to_dest *) xmalloc (sizeof *ent);
- ent->name = name;
+ ent->name = xstrdup (name);
ent->st_ino = ino;
ent->st_dev = dev;
@@ -134,7 +142,8 @@ hash_init (void)
{
src_to_dest = hash_initialize (INITIAL_TABLE_SIZE, NULL,
src_to_dest_hash,
- src_to_dest_compare, free);
+ src_to_dest_compare,
+ src_to_dest_free);
if (src_to_dest == NULL)
xalloc_die ();
}