Skip to content

Commit

Permalink
fix(rcomb,rmtxop): Fix to matrix deallocation
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregungory committed Nov 8, 2024
1 parent 2fc3a9e commit 9b97da7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/util/rcomb.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef lint
static const char RCSid[] = "$Id: rcomb.c,v 2.25 2024/08/21 01:09:25 greg Exp $";
static const char RCSid[] = "$Id: rcomb.c,v 2.26 2024/11/08 17:52:26 greg Exp $";
#endif
/*
* General component matrix combiner, operating on a row at a time.
Expand Down Expand Up @@ -852,7 +852,7 @@ resize_inparr(int n2alloc)

if (n2alloc == nall)
return;
for (i = nall; i > n2alloc; i--) {
for (i = nall; i-- > n2alloc; ) {
rmx_reset(&mop[i].imx);
if (mop[i].rmp != &mop[i].imx)
rmx_free(mop[i].rmp);
Expand Down
32 changes: 16 additions & 16 deletions src/util/rmtxop.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef lint
static const char RCSid[] = "$Id: rmtxop.c,v 2.34 2024/08/21 01:09:25 greg Exp $";
static const char RCSid[] = "$Id: rmtxop.c,v 2.35 2024/11/08 17:52:26 greg Exp $";
#endif
/*
* General component matrix operations.
Expand Down Expand Up @@ -34,7 +34,7 @@ typedef struct {
int verbose = 0; /* verbose reporting? */

/* Load matrix */
static int
int
loadmatrix(ROPMAT *rop)
{
if (rop->mtx != NULL) /* already loaded? */
Expand All @@ -45,10 +45,10 @@ loadmatrix(ROPMAT *rop)
return(!rop->mtx ? -1 : 1);
}

static int checksymbolic(ROPMAT *rop);
extern int checksymbolic(ROPMAT *rop);

/* Check/set transform based on a reference input file */
static int
int
checkreffile(ROPMAT *rop)
{
static const char *curRF = NULL;
Expand Down Expand Up @@ -107,7 +107,7 @@ checkreffile(ROPMAT *rop)
}

/* Compute conversion row from spectrum to one channel of RGB */
static void
void
rgbrow(ROPMAT *rop, int r, int p)
{
const int nc = rop->mtx->ncomp;
Expand All @@ -124,7 +124,7 @@ rgbrow(ROPMAT *rop, int r, int p)
}

/* Compute conversion row from spectrum to one channel of XYZ */
static void
void
xyzrow(ROPMAT *rop, int r, int p)
{
const int nc = rop->mtx->ncomp;
Expand All @@ -141,7 +141,7 @@ xyzrow(ROPMAT *rop, int r, int p)
}

/* Use the spectral sensitivity function to compute matrix coefficients */
static void
void
sensrow(ROPMAT *rop, int r, double (*sf)(const SCOLOR sc, int ncs, const float wlpt[4]))
{
const int nc = rop->mtx->ncomp;
Expand All @@ -156,7 +156,7 @@ sensrow(ROPMAT *rop, int r, double (*sf)(const SCOLOR sc, int ncs, const float w
}

/* Check/set symbolic transform */
static int
int
checksymbolic(ROPMAT *rop)
{
const int nc = rop->mtx->ncomp;
Expand Down Expand Up @@ -267,7 +267,7 @@ checksymbolic(ROPMAT *rop)
}

/* Get matrix and perform unary operations */
static RMATRIX *
RMATRIX *
loadop(ROPMAT *rop)
{
int outtype = 0;
Expand Down Expand Up @@ -367,7 +367,7 @@ loadop(ROPMAT *rop)
}

/* Execute binary operation, free matrix arguments and return new result */
static RMATRIX *
RMATRIX *
binaryop(const char *inspec, RMATRIX *mleft, int op, RMATRIX *mright)
{
RMATRIX *mres = NULL;
Expand Down Expand Up @@ -444,7 +444,7 @@ binaryop(const char *inspec, RMATRIX *mleft, int op, RMATRIX *mright)
}

/* Perform matrix operations from left to right */
static RMATRIX *
RMATRIX *
op_left2right(ROPMAT *mop)
{
RMATRIX *mleft = loadop(mop);
Expand All @@ -460,7 +460,7 @@ op_left2right(ROPMAT *mop)
}

/* Perform matrix operations from right to left */
static RMATRIX *
RMATRIX *
op_right2left(ROPMAT *mop)
{
RMATRIX *mright;
Expand Down Expand Up @@ -489,7 +489,7 @@ op_right2left(ROPMAT *mop)
: (mop)->mtx->ncols)

/* Should we prefer concatenating from rightmost matrix towards left? */
static int
int
prefer_right2left(ROPMAT *mop)
{
int mri = 0;
Expand All @@ -516,7 +516,7 @@ prefer_right2left(ROPMAT *mop)
return(t_ncols(mop+mri) < t_nrows(mop));
}

static int
int
get_factors(double da[], int n, char *av[])
{
int ac;
Expand All @@ -526,15 +526,15 @@ get_factors(double da[], int n, char *av[])
return(ac);
}

static ROPMAT *
ROPMAT *
resize_moparr(ROPMAT *mop, int n2alloc)
{
int nmats = 0;
int i;

while (mop[nmats++].binop)
;
for (i = nmats; i > n2alloc; i--)
for (i = nmats; i >= n2alloc; i--)
rmx_free(mop[i].mtx);
mop = (ROPMAT *)realloc(mop, n2alloc*sizeof(ROPMAT));
if (mop == NULL) {
Expand Down

0 comments on commit 9b97da7

Please sign in to comment.