}
#ifdef ENABLE_CYCLE_CHECK
- if (S_ISDIR (filetype_mode))
+ if (x->recursive && S_ISDIR (filetype_mode))
{
struct active_dir_ent *old_ent;
struct active_dir_ent *new_ent;
status = remove_dir (fs, need_save_cwd, x, cwd_dev_ino);
#ifdef ENABLE_CYCLE_CHECK
- {
- struct active_dir_ent tmp;
- struct active_dir_ent *old_ent;
-
- /* Remove this directory from the active_dir_map. */
- tmp.st_ino = fs->st_ino;
- assert (fs->have_device);
- tmp.st_dev = fs->st_dev;
- old_ent = hash_delete (active_dir_map, &tmp);
- assert (old_ent != NULL);
- free (old_ent);
- }
+ if (active_dir_map)
+ {
+ struct active_dir_ent tmp;
+ struct active_dir_ent *old_ent;
+
+ /* Remove this directory from the active_dir_map. */
+ tmp.st_ino = fs->st_ino;
+ assert (fs->have_device);
+ tmp.st_dev = fs->st_dev;
+ old_ent = hash_delete (active_dir_map, &tmp);
+ assert (old_ent != NULL);
+ free (old_ent);
+ }
#endif
return status;
}
void
-remove_init (void)
+remove_init (struct rm_options const *x)
{
/* Initialize dir-stack obstacks. */
obstack_init (&dir_stack);
obstack_init (&len_stack);
#ifdef ENABLE_CYCLE_CHECK
- active_dir_map = hash_initialize (ACTIVE_DIR_INITIAL_CAPACITY, NULL,
- hash_active_dir_ent,
- hash_compare_active_dir_ents, free);
+ if (x->recursive)
+ active_dir_map
+ = hash_initialize (ACTIVE_DIR_INITIAL_CAPACITY, NULL,
+ hash_active_dir_ent,
+ hash_compare_active_dir_ents, free);
#endif
}
remove_fini (void)
{
#ifdef ENABLE_CYCLE_CHECK
- hash_free (active_dir_map);
+ if (active_dir_map)
+ hash_free (active_dir_map);
#endif
obstack_free (&dir_stack, NULL);