[asterisk-commits] trunk r34498 - /trunk/build_tools/menuselect.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Jun 16 09:58:51 MST 2006
Author: russell
Date: Fri Jun 16 11:58:51 2006
New Revision: 34498
URL: http://svn.digium.com/view/asterisk?rev=34498&view=rev
Log:
remove prototypes for static functions and fix some potential memory leaks
Modified:
trunk/build_tools/menuselect.c
Modified: trunk/build_tools/menuselect.c
URL: http://svn.digium.com/view/asterisk/trunk/build_tools/menuselect.c?rev=34498&r1=34497&r2=34498&view=diff
==============================================================================
--- trunk/build_tools/menuselect.c (original)
+++ trunk/build_tools/menuselect.c Fri Jun 16 11:58:51 2006
@@ -73,18 +73,6 @@
/*! 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)
{
@@ -127,6 +115,19 @@
AST_LIST_INSERT_TAIL(&cat->members, mem, list);
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 */
@@ -203,8 +204,10 @@
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 @@
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 @@
}
if (add_member(mem, cat))
- free(mem);
+ free_member(mem);
}
}
More information about the asterisk-commits
mailing list