diff --git a/src/copy.c b/src/copy.c index 9fb2420e1..26ab909fd 100644 --- a/src/copy.c +++ b/src/copy.c @@ -1957,6 +1957,16 @@ dest_info_init (struct cp_options *x) xalloc_die (); } +#ifdef lint +extern void +dest_info_free (struct cp_options *x) +{ + if (x->dest_info) + hash_free (x->dest_info); + x->dest_info = NULL; +} +#endif + /* Initialize the hash table implementing a set of F_triple entries corresponding to source files listed on the command line. */ extern void @@ -1981,6 +1991,16 @@ src_info_init (struct cp_options *x) xalloc_die (); } +#ifdef lint +extern void +src_info_free (struct cp_options *x) +{ + if (x->src_info) + hash_free (x->src_info); + x->src_info = NULL; +} +#endif + /* When effecting a move (e.g., for mv(1)), and given the name DST_NAME of the destination and a corresponding stat buffer, DST_SB, return true if the logical 'move' operation should _not_ proceed. diff --git a/src/copy.h b/src/copy.h index 026530518..a97089137 100644 --- a/src/copy.h +++ b/src/copy.h @@ -300,7 +300,9 @@ extern bool set_file_security_ctx (char const *dst_name, bool recurse, const struct cp_options *x); void dest_info_init (struct cp_options *); +void dest_info_free (struct cp_options *); void src_info_init (struct cp_options *); +void src_info_free (struct cp_options *); void cp_options_default (struct cp_options *); bool chown_failure_ok (struct cp_options const *) _GL_ATTRIBUTE_PURE; diff --git a/src/cp-hash.c b/src/cp-hash.c index 423fcda23..1223c8aed 100644 --- a/src/cp-hash.c +++ b/src/cp-hash.c @@ -157,8 +157,10 @@ hash_init (void) /* Reset the hash structure in the global variable 'htab' to contain no entries. */ +#ifdef lint extern void forget_all (void) { hash_free (src_to_dest); } +#endif diff --git a/src/cp.c b/src/cp.c index a420c592b..c97a67563 100644 --- a/src/cp.c +++ b/src/cp.c @@ -730,6 +730,11 @@ do_copy (int n_files, char **file, char const *target_directory, free (dst_name); } + +#ifdef lint + dest_info_free (x); + src_info_free (x); +#endif } else /* !target_directory */ { diff --git a/src/install.c b/src/install.c index 8edf00f93..c9456fe5d 100644 --- a/src/install.c +++ b/src/install.c @@ -1017,6 +1017,9 @@ main (int argc, char **argv) if (! install_file_in_dir (file[i], target_directory, &x, i == 0 && mkdir_and_install)) exit_status = EXIT_FAILURE; +#ifdef lint + dest_info_free (&x); +#endif } } diff --git a/src/ln.c b/src/ln.c index 760bab25a..c7eb74026 100644 --- a/src/ln.c +++ b/src/ln.c @@ -680,6 +680,12 @@ main (int argc, char **argv) ok &= do_link (file[i], destdir_fd, dest_base, dest, -1); free (dest); } + +#ifdef lint + if (dest_set) + hash_free (dest_set); + dest_set = NULL; +#endif } else ok = do_link (file[0], AT_FDCWD, file[1], file[1], link_errno); diff --git a/src/mv.c b/src/mv.c index 3db5cc48d..7d81b59a7 100644 --- a/src/mv.c +++ b/src/mv.c @@ -503,6 +503,10 @@ main (int argc, char **argv) x.last_file = i + 1 == n_files; ok &= movefile (file[i], target_directory, true, &x); } + +#ifdef lint + dest_info_free (&x); +#endif } else { diff --git a/src/tail.c b/src/tail.c index 9095a18d8..ff567560d 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1568,7 +1568,12 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, return true; } if (follow_mode == Follow_descriptor && !found_watchable_file) - return false; + { +# ifdef lint + hash_free (wd_to_name); +# endif + return false; + } prev_fspec = &(f[n_files - 1]); @@ -1626,6 +1631,9 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, && hash_get_n_entries (wd_to_name) == 0) { error (0, 0, _("no files remaining")); +# ifdef lint + hash_free (wd_to_name); +# endif return false; }