Use popMacro() when freeing the entire macro table

- We already have a function to free macro entries, use it to
  remove code duplication
This commit is contained in:
Panu Matilainen 2011-05-31 10:38:17 +03:00
parent a5eefce1bf
commit 6c391a88fa
1 changed files with 4 additions and 11 deletions

View File

@ -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));
}