diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-06-16 16:58:51 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-06-16 16:58:51 +0000 |
commit | 98594f5ab388d66be5994105a56a5ea4ab670c40 (patch) | |
tree | fc46863fee5d12e127e2a4a055766e9b88981db9 /build_tools | |
parent | c521e839954238b8a1818dacc9590b6db4c2bf9d (diff) |
remove prototypes for static functions and fix some potential memory leaks
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@34498 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'build_tools')
-rw-r--r-- | build_tools/menuselect.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/build_tools/menuselect.c b/build_tools/menuselect.c index d2427359f..68afeed44 100644 --- a/build_tools/menuselect.c +++ b/build_tools/menuselect.c @@ -73,18 +73,6 @@ static int check_deps = 0; /*! Force a clean of the source tree */ static int force_clean = 0; -static int add_category(struct category *cat); -static int add_member(struct member *mem, struct category *cat); -static int parse_makeopts_xml(const char *makeopts_xml); -static int process_deps(void); -static int build_member_list(void); -static void mark_as_present(const char *member, const char *category); -static void process_prev_failed_deps(char *buf); -static int parse_existing_config(const char *infile); -static int generate_makeopts_file(void); -static void free_member_list(void); -static void free_trees(void); - /*! \brief return a pointer to the first non-whitespace character */ static inline char *skip_blanks(char *str) { @@ -129,6 +117,19 @@ static int add_member(struct member *mem, struct category *cat) return 0; } +/*! \brief Free a member structure and all of its members */ +static void free_member(struct member *mem) +{ + struct depend *dep; + struct conflict *cnf; + + while ((dep = AST_LIST_REMOVE_HEAD(&mem->deps, list))) + free(dep); + while ((cnf = AST_LIST_REMOVE_HEAD(&mem->conflicts, list))) + free(cnf); + free(mem); +} + /*! \brief Parse an input makeopts file */ static int parse_makeopts_xml(const char *makeopts_xml) { @@ -203,8 +204,10 @@ static int parse_makeopts_xml(const char *makeopts_xml) cur3 && cur3->child; cur3 = mxmlFindElement(cur3, cur2, "depend", NULL, NULL, MXML_DESCEND)) { - if (!(dep = calloc(1, sizeof(*dep)))) + if (!(dep = calloc(1, sizeof(*dep)))) { + free_member(mem); return -1; + } if (!strlen_zero(cur3->child->value.opaque)) { dep->name = cur3->child->value.opaque; AST_LIST_INSERT_HEAD(&mem->deps, dep, list); @@ -216,8 +219,10 @@ static int parse_makeopts_xml(const char *makeopts_xml) cur3 && cur3->child; cur3 = mxmlFindElement(cur3, cur2, "conflict", NULL, NULL, MXML_DESCEND)) { - if (!(cnf = calloc(1, sizeof(*cnf)))) + if (!(cnf = calloc(1, sizeof(*cnf)))) { + free_member(mem); return -1; + } if (!strlen_zero(cur3->child->value.opaque)) { cnf->name = cur3->child->value.opaque; AST_LIST_INSERT_HEAD(&mem->conflicts, cnf, list); @@ -226,7 +231,7 @@ static int parse_makeopts_xml(const char *makeopts_xml) } if (add_member(mem, cat)) - free(mem); + free_member(mem); } } |