The following commit has been merged in the master branch:
commit 82f4497f3bbe41d52fe697868d53732bb355da81
Author: Guillem Jover <[email protected]>
Date: Tue Sep 13 05:19:50 2011 +0200
u-a: Free struct alternative_map variables
Take references when adding duplicate entries of the same alternative
on load, and add a new alternative_map_free() function to free an
alternative_map variable.
diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 2107241..81055b4 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -1975,15 +1975,32 @@ alternative_map_load_tree(struct alternative_map
*alt_map_links,
continue;
}
alternative_map_add(alt_map_links, a_new->master_link, a_new);
+ alternative_ref(a_new);
alternative_map_add(alt_map_parent, a_new->master_name, a_new);
for (sl = a_new->slaves; sl; sl = sl->next) {
+ alternative_ref(a_new);
alternative_map_add(alt_map_links, sl->link, a_new);
+ alternative_ref(a_new);
alternative_map_add(alt_map_parent, sl->name, a_new);
}
}
altdb_free_namelist(table, count);
}
+static void
+alternative_map_free(struct alternative_map *am)
+{
+ struct alternative_map *am_next;
+
+ while (am) {
+ am_next = am->next;
+ if (am->item)
+ alternative_free(am->item);
+ free(am);
+ am = am_next;
+ }
+}
+
static const char *
get_argv_string(int argc, char **argv)
{
@@ -2266,6 +2283,9 @@ alternative_check_install_args(struct alternative
*inst_alt,
alternative_check_args(sl->name, sl->link, file);
}
+
+ alternative_map_free(alt_map_links);
+ alternative_map_free(alt_map_parent);
}
/*
@@ -2458,6 +2478,8 @@ main(int argc, char **argv)
free(current);
}
+ alternative_map_free(alt_map_obj);
+
exit(0);
} else if (strcmp(action, "set-selections") == 0) {
struct alternative_map *alt_map_obj;
@@ -2466,6 +2488,7 @@ main(int argc, char **argv)
alt_map_obj = alternative_map_new(NULL, NULL);
alternative_map_load_names(alt_map_obj);
alternative_set_selections(alt_map_obj, stdin, _("<standard
input>"));
+ alternative_map_free(alt_map_obj);
exit(0);
}
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]