It appears order may matter here. Use OrderedHashmaps to be safe.
#include "special.h"
typedef struct {
#include "special.h"
typedef struct {
- Hashmap *will_install;
- Hashmap *have_installed;
+ OrderedHashmap *will_install;
+ OrderedHashmap *have_installed;
} InstallContext;
static int in_search_path(const char *path, char **search) {
} InstallContext;
static int in_search_path(const char *path, char **search) {
-static void install_info_hashmap_free(Hashmap *m) {
+static void install_info_hashmap_free(OrderedHashmap *m) {
InstallInfo *i;
if (!m)
return;
InstallInfo *i;
if (!m)
return;
- while ((i = hashmap_steal_first(m)))
+ while ((i = ordered_hashmap_steal_first(m)))
+ ordered_hashmap_free(m);
}
static void install_context_done(InstallContext *c) {
}
static void install_context_done(InstallContext *c) {
if (!unit_name_is_valid(name, TEMPLATE_VALID))
return -EINVAL;
if (!unit_name_is_valid(name, TEMPLATE_VALID))
return -EINVAL;
- if (hashmap_get(c->have_installed, name) ||
- hashmap_get(c->will_install, name))
+ if (ordered_hashmap_get(c->have_installed, name) ||
+ ordered_hashmap_get(c->will_install, name))
- r = hashmap_ensure_allocated(&c->will_install, &string_hash_ops);
+ r = ordered_hashmap_ensure_allocated(&c->will_install, &string_hash_ops);
- r = hashmap_put(c->will_install, i->name, i);
+ r = ordered_hashmap_put(c->will_install, i->name, i);
- assert_se(i = hashmap_first(c.will_install));
+ assert_se(i = ordered_hashmap_first(c.will_install));
r = unit_file_search(&c, i, paths, root_dir, allow_symlink, true);
r = unit_file_search(&c, i, paths, root_dir, allow_symlink, true);
assert(paths);
assert(config_path);
assert(paths);
assert(config_path);
- while ((i = hashmap_first(c->will_install))) {
+ while ((i = ordered_hashmap_first(c->will_install))) {
- q = hashmap_ensure_allocated(&c->have_installed, &string_hash_ops);
+ q = ordered_hashmap_ensure_allocated(&c->have_installed, &string_hash_ops);
- assert_se(hashmap_move_one(c->have_installed, c->will_install, i->name) == 0);
+ assert_se(ordered_hashmap_move_one(c->have_installed, c->will_install, i->name) == 0);
q = unit_file_search(c, i, paths, root_dir, false, true);
if (q < 0) {
q = unit_file_search(c, i, paths, root_dir, false, true);
if (q < 0) {
/* Marks all items for removal */
/* Marks all items for removal */
- while ((i = hashmap_first(c->will_install))) {
+ while ((i = ordered_hashmap_first(c->will_install))) {
- q = hashmap_ensure_allocated(&c->have_installed, &string_hash_ops);
+ q = ordered_hashmap_ensure_allocated(&c->have_installed, &string_hash_ops);
- assert_se(hashmap_move_one(c->have_installed, c->will_install, i->name) == 0);
+ assert_se(ordered_hashmap_move_one(c->have_installed, c->will_install, i->name) == 0);
q = unit_file_search(c, i, paths, root_dir, false, true);
if (q == -ENOENT) {
q = unit_file_search(c, i, paths, root_dir, false, true);
if (q == -ENOENT) {
- while ((info = hashmap_first(c.will_install))) {
- r = hashmap_ensure_allocated(&c.have_installed, &string_hash_ops);
+ while ((info = ordered_hashmap_first(c.will_install))) {
+ r = ordered_hashmap_ensure_allocated(&c.have_installed, &string_hash_ops);
- assert_se(hashmap_move_one(c.have_installed, c.will_install, info->name) == 0);
+ assert_se(ordered_hashmap_move_one(c.have_installed, c.will_install, info->name) == 0);
r = unit_file_search(&c, info, &paths, root_dir, false, false);
if (r < 0)
r = unit_file_search(&c, info, &paths, root_dir, false, false);
if (r < 0)
- assert_se(i = hashmap_first(c.will_install));
+ assert_se(i = ordered_hashmap_first(c.will_install));
r = unit_file_search(&c, i, &paths, root_dir, false, true);
if (r < 0)
r = unit_file_search(&c, i, &paths, root_dir, false, true);
if (r < 0)