Clean up + clarify popMacro() a bit

- Actually protect against NULL mep (shouldn't happen but...)
- Remove bogus comment + add actually relevant comments
- Make the *mep reassignment more obvious by taking it out of
  the if where its easily missed
- Replace dead NULL-assignments with a trash-n-burn memset()
- Fixup indentation to match general rpm style
This commit is contained in:
Panu Matilainen 2011-05-31 11:38:38 +03:00
parent 6c391a88fa
commit bd4fc30884
1 changed files with 14 additions and 9 deletions

View File

@ -691,16 +691,21 @@ pushMacro(rpmMacroEntry * mep,
static void static void
popMacro(rpmMacroEntry * mep) popMacro(rpmMacroEntry * mep)
{ {
rpmMacroEntry me = (*mep ? *mep : NULL); if (mep && *mep) {
rpmMacroEntry me = *mep;
if (me) { /* restore previous definition of the macro */
/* XXX cast to workaround const */ *mep = me->prev;
if ((*mep = me->prev) == NULL)
me->name = _free(me->name); /* name is shared between entries, only free if last of its kind */
me->opts = _free(me->opts); if (me->prev == NULL)
me->body = _free(me->body); free(me->name);
me = _free(me); free(me->opts);
} free(me->body);
memset(me, 0, sizeof(*me)); /* trash and burn */
free(me);
}
} }
/** /**