From 6c391a88fa9914cdabef6f7b1ced63f23ab9ceca Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Tue, 31 May 2011 10:38:17 +0300 Subject: [PATCH] Use popMacro() when freeing the entire macro table - We already have a function to free macro entries, use it to remove code duplication --- rpmio/macro.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/rpmio/macro.c b/rpmio/macro.c index edf0c7f..f5488a6 100644 --- a/rpmio/macro.c +++ b/rpmio/macro.c @@ -1529,19 +1529,12 @@ rpmFreeMacros(rpmMacroContext mc) if (mc == NULL) mc = rpmGlobalMacroContext; if (mc->macroTable != NULL) { - int i; - for (i = 0; i < mc->firstFree; i++) { - rpmMacroEntry me; - while ((me = mc->macroTable[i]) != NULL) { - /* XXX cast to workaround const */ - if ((mc->macroTable[i] = me->prev) == NULL) - me->name = _free(me->name); - me->opts = _free(me->opts); - me->body = _free(me->body); - me = _free(me); + for (int i = 0; i < mc->firstFree; i++) { + while (mc->macroTable[i] != NULL) { + popMacro(&mc->macroTable[i]); } } - mc->macroTable = _free(mc->macroTable); + free(mc->macroTable); } memset(mc, 0, sizeof(*mc)); } -- 2.7.4