summaryrefslogtreecommitdiffstats
path: root/builtin/submodule--helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/submodule--helper.c')
-rw-r--r--builtin/submodule--helper.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index ebd00f57e5..65cd25a251 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -172,6 +172,11 @@ struct module_list {
};
#define MODULE_LIST_INIT { 0 }
+static void module_list_release(struct module_list *ml)
+{
+ free(ml->entries);
+}
+
static int module_list_compute(int argc, const char **argv,
const char *prefix,
struct pathspec *pathspec,
@@ -234,7 +239,7 @@ static void module_list_active(struct module_list *list)
active_modules.entries[active_modules.nr++] = ce;
}
- free(list->entries);
+ module_list_release(list);
*list = active_modules;
}
@@ -407,6 +412,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix)
ret = 0;
cleanup:
+ module_list_release(&list);
clear_pathspec(&pathspec);
return ret;
}
@@ -553,6 +559,7 @@ static int module_init(int argc, const char **argv, const char *prefix)
ret = 0;
cleanup:
+ module_list_release(&list);
clear_pathspec(&pathspec);
return ret;
}
@@ -730,6 +737,7 @@ static int module_status(int argc, const char **argv, const char *prefix)
ret = 0;
cleanup:
+ module_list_release(&list);
clear_pathspec(&pathspec);
return ret;
}
@@ -1302,6 +1310,7 @@ static int module_sync(int argc, const char **argv, const char *prefix)
ret = 0;
cleanup:
+ module_list_release(&list);
clear_pathspec(&pathspec);
return ret;
}
@@ -1454,6 +1463,7 @@ static int module_deinit(int argc, const char **argv, const char *prefix)
ret = 0;
cleanup:
+ module_list_release(&list);
clear_pathspec(&pathspec);
return ret;
}
@@ -1831,6 +1841,12 @@ struct submodule_update_clone {
};
#define SUBMODULE_UPDATE_CLONE_INIT { 0 }
+static void submodule_update_clone_release(struct submodule_update_clone *suc)
+{
+ free(suc->update_clone);
+ free(suc->failed_clones);
+}
+
struct update_data {
const char *prefix;
const char *displaypath;
@@ -1869,6 +1885,11 @@ struct update_data {
.max_jobs = 1, \
}
+static void update_data_release(struct update_data *ud)
+{
+ module_list_release(&ud->list);
+}
+
static void next_submodule_warn_missing(struct submodule_update_clone *suc,
struct strbuf *out, const char *displaypath)
{
@@ -2554,6 +2575,7 @@ static int update_submodules(struct update_data *update_data)
}
cleanup:
+ submodule_update_clone_release(&suc);
string_list_clear(&update_data->references, 0);
return ret;
}
@@ -2651,6 +2673,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
if (module_list_compute(argc, argv, opt.prefix,
&pathspec2, &list) < 0) {
+ module_list_release(&list);
ret = 1;
goto cleanup;
}
@@ -2667,10 +2690,12 @@ static int module_update(int argc, const char **argv, const char *prefix)
info.flags |= OPT_QUIET;
for_each_listed_submodule(&list, init_submodule_cb, &info);
+ module_list_release(&list);
}
ret = update_submodules(&opt);
cleanup:
+ update_data_release(&opt);
list_objects_filter_release(&filter_options);
clear_pathspec(&pathspec);
clear_pathspec(&pathspec2);
@@ -2786,6 +2811,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
ret = 0;
cleanup:
clear_pathspec(&pathspec);
+ module_list_release(&list);
return ret;
}