From 61b95dac6923f9ee9a53f3a42bef8124b932ac06 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 7 Oct 2001 08:41:03 +0000 Subject: (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. --- src/cp-hash.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') 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 (); } -- cgit v1.2.3-54-g00ecf