2006-07-03 Jim Meyering <jim@meyering.net>
+ Plug another unusual leak.
+ (AD_mark_helper): Free malloc'd filename if hash_insert says
+ that string is already in the hash table.
+
The dev/inode of the topmost directory in each hierarchy were not
being recorded.
* src/remove.c (remove_cwd_entries): Don't call cycle_check here.
/* Initialize *HT if it is NULL.
Insert FILENAME into HT. */
static void
-AD_mark_helper (Hash_table **ht, char const *filename)
+AD_mark_helper (Hash_table **ht, char *filename)
{
if (*ht == NULL)
{
if (*ht == NULL)
xalloc_die ();
}
- if (! hash_insert (*ht, filename))
+ void *ent = hash_insert (*ht, filename);
+ if (ent == NULL)
xalloc_die ();
+ else
+ {
+ if (ent != filename)
+ free (filename);
+ }
+
}
/* Mark FILENAME (in current directory) as unremovable. */
AD_mark_current_as_unremovable (Dirstack_state *ds)
{
struct AD_ent *top = AD_stack_top (ds);
- char const *curr = top_dir (ds);
+ char *curr = top_dir (ds);
assert (1 < AD_stack_height (ds));