Browse Source

* convolution.c: fix a small memory leak in the convolution filter.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2684 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 16 years ago
parent
commit
1ff729fd7b
1 changed files with 7 additions and 2 deletions
  1. +7
    -2
      pipi/filter/convolution.c

+ 7
- 2
pipi/filter/convolution.c View File

@@ -35,6 +35,7 @@ static pipi_image_t *pipi_convolution_separable(pipi_image_t *src,

pipi_image_t *pipi_convolution(pipi_image_t *src, int m, int n, double mat[])
{
pipi_image_t *ret;
double tmp;
double *hvec, *vvec;
int i, j, besti = -1, bestj = -1;
@@ -75,7 +76,6 @@ pipi_image_t *pipi_convolution(pipi_image_t *src, int m, int n, double mat[])
}

/* Matrix rank is 1! Separate the filter */
/* FIXME: memleak */
hvec = malloc(m * sizeof(double));
vvec = malloc(n * sizeof(double));

@@ -85,7 +85,12 @@ pipi_image_t *pipi_convolution(pipi_image_t *src, int m, int n, double mat[])
for(j = 0; j < n; j++)
vvec[j] = mat[j * m + besti] / tmp;

return pipi_convolution_separable(src, m, hvec, n, vvec);
ret = pipi_convolution_separable(src, m, hvec, n, vvec);

free(hvec);
free(vvec);

return ret;
}

static pipi_image_t *pipi_convolution_standard(pipi_image_t *src,


Loading…
Cancel
Save