Skip to content

Commit

Permalink
refactor(dracut-install): add Hashmap cleanup function
Browse files Browse the repository at this point in the history
This is prep work for adding support for fw_devlink suppliers
dependencies.

Signed-off-by: Adrien Thierry <athierry@redhat.com>
  • Loading branch information
athierry1 authored and johannbg committed Feb 13, 2023
1 parent 8ea8cf5 commit f0c3b68
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/install/dracut-install.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ static bool arg_mod_filter_noname = false;
static int dracut_install(const char *src, const char *dst, bool isdir, bool resolvedeps, bool hashdst);
static int install_dependent_modules(struct kmod_list *modlist);

static void item_free(char *i)
{
assert(i);
free(i);
}

static inline void kmod_module_unrefp(struct kmod_module **p)
{
if (*p)
Expand Down Expand Up @@ -145,6 +151,18 @@ static inline void fts_closep(FTS **p)

#define _cleanup_globfree_ _cleanup_(globfree)

static inline void destroy_hashmap(Hashmap **hashmap)
{
void *i = NULL;

while ((i = hashmap_steal_first(*hashmap)))
item_free(i);

hashmap_free(*hashmap);
}

#define _cleanup_destroy_hashmap_ _cleanup_(destroy_hashmap)

static size_t dir_len(char const *file)
{
size_t length;
Expand Down Expand Up @@ -938,12 +956,6 @@ static int dracut_install(const char *orig_src, const char *orig_dst, bool isdir
return ret;
}

static void item_free(char *i)
{
assert(i);
free(i);
}

static void usage(int status)
{
/* */
Expand Down

0 comments on commit f0c3b68

Please sign in to comment.