summaryrefslogtreecommitdiff
path: root/rpmio/macro.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2011-05-31 11:38:38 +0300
committerPanu Matilainen <pmatilai@redhat.com>2011-05-31 11:38:38 +0300
commitbd4fc3088451b9aec63bfd75478ceb43ae80de59 (patch)
treefa60295dd94ac85ab5848c2e27dc1d1395c345e4 /rpmio/macro.c
parent6c391a88fa9914cdabef6f7b1ced63f23ab9ceca (diff)
downloadrpm-bd4fc3088451b9aec63bfd75478ceb43ae80de59.tar.gz
rpm-bd4fc3088451b9aec63bfd75478ceb43ae80de59.tar.bz2
rpm-bd4fc3088451b9aec63bfd75478ceb43ae80de59.zip
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
Diffstat (limited to 'rpmio/macro.c')
-rw-r--r--rpmio/macro.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/rpmio/macro.c b/rpmio/macro.c
index f5488a685..9667d71e2 100644
--- a/rpmio/macro.c
+++ b/rpmio/macro.c
@@ -691,16 +691,21 @@ pushMacro(rpmMacroEntry * mep,
static void
popMacro(rpmMacroEntry * mep)
{
- rpmMacroEntry me = (*mep ? *mep : NULL);
-
- if (me) {
- /* XXX cast to workaround const */
- if ((*mep = me->prev) == NULL)
- me->name = _free(me->name);
- me->opts = _free(me->opts);
- me->body = _free(me->body);
- me = _free(me);
- }
+ if (mep && *mep) {
+ rpmMacroEntry me = *mep;
+
+ /* restore previous definition of the macro */
+ *mep = me->prev;
+
+ /* name is shared between entries, only free if last of its kind */
+ if (me->prev == NULL)
+ free(me->name);
+ free(me->opts);
+ free(me->body);
+
+ memset(me, 0, sizeof(*me)); /* trash and burn */
+ free(me);
+ }
}
/**