[Gfxprim] [repo.or.cz] gfxprim.git branch master updated: 62f5963ad7a384999f52b96a18f5c253cde5290c

metan metan at ucw.cz
Sat Jul 21 23:16:23 CEST 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.

The branch, master has been updated
       via  62f5963ad7a384999f52b96a18f5c253cde5290c (commit)
      from  c5df8a737efa84871a78e5ee6a165cbaaa6ed90f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/62f5963ad7a384999f52b96a18f5c253cde5290c

commit 62f5963ad7a384999f52b96a18f5c253cde5290c
Author: Cyril Hrubis <metan at ucw.cz>
Date:   Sat Jul 21 23:14:56 2012 +0200

    filters: Median: clean up allocated memory correctly.

diff --git a/libs/filters/GP_Median.c b/libs/filters/GP_Median.c
index 974e140..88dd92c 100644
--- a/libs/filters/GP_Median.c
+++ b/libs/filters/GP_Median.c
@@ -175,6 +175,9 @@ static int GP_FilterMedian_Raw(const GP_Context *src,
 {
 	int i, x, y;
 
+	//TODO
+	GP_CHECK(src->pixel_type == GP_PIXEL_RGB888);
+
 	GP_DEBUG(1, "Median filter size %ux%u xmed=%u ymed=%u",
 	            w_src, h_src, 2 * xmed + 1, 2 * ymed + 1);
 	
@@ -182,15 +185,19 @@ static int GP_FilterMedian_Raw(const GP_Context *src,
 	unsigned int size = (w_src + 2 * xmed + 1);
 
 	/* Create and initalize arrays for row of histograms */
-	GP_TempAllocCreate(temp, 3 * sizeof(struct hist8) * size);
+	GP_TempAllocCreate(temp, 3 * sizeof(struct hist8) * size + 3 * sizeof(struct hist8u));
 
 	struct hist8 *R = GP_TempAllocGet(temp, sizeof(struct hist8) * size);
 	struct hist8 *G = GP_TempAllocGet(temp, sizeof(struct hist8) * size);
 	struct hist8 *B = GP_TempAllocGet(temp, sizeof(struct hist8) * size);
 	
-	memset(R, 0, sizeof(*R));
-	memset(G, 0, sizeof(*G));
-	memset(B, 0, sizeof(*B));
+	memset(R, 0, sizeof(*R) * size);
+	memset(G, 0, sizeof(*G) * size);
+	memset(B, 0, sizeof(*B) * size);
+
+	struct hist8u *XR = GP_TempAllocGet(temp, sizeof(struct hist8u));
+	struct hist8u *XG = GP_TempAllocGet(temp, sizeof(struct hist8u));
+	struct hist8u *XB = GP_TempAllocGet(temp, sizeof(struct hist8u));
 
 	/* Prefill row of histograms */
 	for (x = 0; x < (int)w_src + 2*xmed; x++) {
@@ -209,9 +216,6 @@ static int GP_FilterMedian_Raw(const GP_Context *src,
 
 	/* Apply the median filter */
 	for (y = 0; y < (int)h_src; y++) {
-		struct hist8u xR, xG, xB;
-		struct hist8u *XR = &xR, *XG = &xG, *XB = &xB;
-	
 		memset(XR, 0, sizeof(*XR));
 		memset(XG, 0, sizeof(*XG));
 		memset(XB, 0, sizeof(*XB));

-----------------------------------------------------------------------

Summary of changes:
 libs/filters/GP_Median.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)


repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos at gmail.com
if you want to unsubscribe, or site admin admin at repo.or.cz if you receive
no reply.
-- 
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")


More information about the Gfxprim mailing list