Skip to content

Commit

Permalink
Replace manual allocations with vectors in skipInstallFiles()
Browse files Browse the repository at this point in the history
  • Loading branch information
pmatilai committed May 22, 2024
1 parent fd0ae59 commit 1a5d530
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "system.h"

#include <set>
#include <vector>

#include <inttypes.h>
#include <libgen.h>
Expand Down Expand Up @@ -47,6 +48,8 @@

#include "debug.h"

using std::vector;

struct diskspaceInfo_s {
char * mntPoint; /*!< File system mount point */
dev_t dev; /*!< File system device number. */
Expand Down Expand Up @@ -838,19 +841,16 @@ static void skipInstallFiles(const rpmts ts, rpmfiles files, rpmfs fs)
int noConfigs = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOCONFIGS);
int noDocs = (rpmtsFlags(ts) & RPMTRANS_FLAG_NODOCS);
int noArtifacts = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOARTIFACTS);
int * drc;
uint8_t * dff;
int dc;
int i, j, ix;
rpmfi fi = rpmfilesIter(files, RPMFI_ITER_FWD);

if (!noDocs)
noDocs = rpmExpandNumeric("%{_excludedocs}");

/* Compute directory refcount, skip directory if now empty. */
dc = rpmfiDC(fi);
drc = (int *)xcalloc(dc, sizeof(*drc));
dff = (uint8_t *)xcalloc(dc, sizeof(*dff));
int dc = rpmfiDC(fi);
vector<int> drc(dc, 0);
vector<uint8_t> dff(dc, 0);

fi = rpmfiInit(fi, 0);
while ((i = rpmfiNext(fi)) >= 0) {
Expand Down Expand Up @@ -998,8 +998,6 @@ static void skipInstallFiles(const rpmts ts, rpmfiles files, rpmfs fs)
}
}

free(drc);
free(dff);
rpmfiFree(fi);
}

Expand Down

0 comments on commit 1a5d530

Please sign in to comment.