Skip to content

Commit

Permalink
Natively allocate rpmte structs and temporary colors vector
Browse files Browse the repository at this point in the history
  • Loading branch information
pmatilai committed Apr 30, 2024
1 parent 1f66db3 commit a0e3dcf
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/rpmte.c
Expand Up @@ -4,6 +4,8 @@
*/
#include "system.h"

#include <vector>

#include <rpm/rpmtypes.h>
#include <rpm/rpmlib.h> /* RPM_MACHTABLE_* */
#include <rpm/rpmmacro.h>
Expand Down Expand Up @@ -256,16 +258,15 @@ rpmte rpmteFree(rpmte te)
rpmpsFree(te->probs);
rpmteCleanDS(te);

memset(te, 0, sizeof(*te)); /* XXX trash and burn */
free(te);
delete te;
}
return NULL;
}

rpmte rpmteNew(rpmts ts, Header h, rpmElementType type, fnpyKey key,
rpmRelocation * relocs, int addop)
{
rpmte p = (rpmte)xcalloc(1, sizeof(*p));
rpmte p = new rpmte_s {};
p->ts = ts;
p->type = type;
p->addop = addop;
Expand Down Expand Up @@ -492,7 +493,6 @@ static void rpmteColorDS(rpmte te, rpmTag tag)
char deptype = rpmdsD(ds);
char mydt;
const uint32_t * ddict;
rpm_color_t * colors;
rpm_color_t val;
int Count;
unsigned ix;
Expand All @@ -501,7 +501,7 @@ static void rpmteColorDS(rpmte te, rpmTag tag)
if (!(te && deptype && (Count = rpmdsCount(ds)) > 0 && rpmfilesFC(te->files) > 0))
return;

colors = (rpm_color_t *)xcalloc(Count, sizeof(*colors));
std::vector<rpm_color_t> colors(Count, 0);

/* Calculate dependency color. */
fi = rpmfilesIter(te->files, RPMFI_ITER_FWD);
Expand All @@ -528,7 +528,6 @@ assert (ix < Count);
te->color |= val;
(void) rpmdsSetColor(ds, val);
}
free(colors);
rpmfiFree(fi);
}

Expand Down

0 comments on commit a0e3dcf

Please sign in to comment.