patches 18-20

[email protected]
Newsgroups gmane.comp.gnu.gift.general
Message-ID <[email protected]>
this is a series of simple pointer error fixes, caught by valgrind.

Comitted.

Julia Longtin <[email protected]>

_______________________________________________
help-GIFT mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gift
18-ChangeLog (text/plain, 595 B)
--- ../../dev3/gift/ChangeLog	2006-11-19 11:38:48.000000000 -0600
+++ ChangeLog	2006-11-19 11:36:05.000000000 -0600
@@ -41,6 +41,10 @@
 	link against .la file, instead of .a file. more portable this way.
 	* libGIFTQuInvertedFile/cc/Makefile.am
 	link against .la file, instead of .a file. more portable this way.
+	* FeatureExtraction/gabor.c
+	fix an off-by-one error in the addressing of value_plane_double_reversed. my fault.
+	* FeatureExtraction/rgb2hsv_utils.c
+	fix an off-by-one error in the addressing of value_plane_double_reversed. my fault.
 
 2006-10-10    <[email protected]>
18-FeatureExtraction_gabor_c-fix_pointer_error.patch (text/plain, 1 KB)
--- ../../anoncvs/gift/FeatureExtraction/gabor.c	2006-10-22 09:59:12.000000000 -0500
+++ FeatureExtraction/gabor.c	2006-11-15 07:33:38.000000000 -0600
@@ -95,7 +95,7 @@
 	target_kernal=kernelsxy[filter_scale*num_gabors_per_scale+orientation];
 	for (x = 0; x < width; x++) {
 	for (y = 0; y < height; y++) {
-		target_image=&image[(width*height)-(y*width+x+kernal_size[filter_scale]/2)];
+		target_image=&image[(width*height-1)-(y*width+x+kernal_size[filter_scale]/2)];
 		if ((x>=kernal_size[filter_scale]/2) && ((x+kernal_size[filter_scale]/2)<width))
 		  {
 		    for (k = 0; k < kernal_size[filter_scale]; k++)
@@ -143,7 +143,7 @@
 	target_kernal=&target_kernal[kernal_size[filter_scale]];
 	for (x = 0; x < width; x++) {
 	for (y = 0; y < height; y++) {
-		target_image=&image[(width*height)-(y*width+x+kernal_size[filter_scale]/2)];
+		target_image=&image[(width*height-1)-(y*width+x+kernal_size[filter_scale]/2)];
 		if ((x>=kernal_size[filter_scale]/2) && ((x+kernal_size[filter_scale]/2)<width))
 		  {
 		    for (k = 0; k < kernal_size[filter_scale]; k++)
18-FeatureExtraction_rgb2hsv_utils_c-fix_pointer_error.patch (text/plain, 591 B)
--- ../../anoncvs/gift/FeatureExtraction/rgb2hsv_utils.c	2006-07-20 12:09:15.000000000 -0500
+++ FeatureExtraction/rgb2hsv_utils.c	2006-11-08 16:09:08.000000000 -0600
@@ -202,7 +202,7 @@
 		(*im_hsv)->pixel[3*i + HUE] = (byte)rint((H/360.0)*max_col);
 		(*im_hsv)->pixel[3*i + SATURATION] = (byte)rint(S*max_col);
 		(*im_hsv)->pixel[3*i + VALUE] = (byte)rint(V*max_col);
-		(*im_hsv)->value_plane_double_reversed[num_pixels-i]=(V*max_col);
+		(*im_hsv)->value_plane_double_reversed[num_pixels-i-1]=(V*max_col);
 	}
 
 	add_comment((*im_hsv), "# Image converted from RGB to HSV format.\n");
19-ChangeLog (text/plain, 552 B)
--- ../../dev3/gift/ChangeLog	2006-11-19 11:48:50.000000000 -0600
+++ ChangeLog	2006-11-19 11:57:06.000000000 -0600
@@ -45,6 +45,8 @@
 	fix an off-by-one error in the addressing of value_plane_double_reversed. my fault.
 	* FeatureExtraction/rgb2hsv_utils.c
 	fix an off-by-one error in the addressing of value_plane_double_reversed. my fault.
+	* FeatureExtraction/gabor.c
+	move from using an array to initialize the size of another array to using a define'd value. one less GCC warning, and slightly faster.
 
 2006-10-10    <[email protected]>
19-FeatureExtraction_gabor_c-remove_array_warning.patch (text/plain, 682 B)
--- ../../dev3/gift/FeatureExtraction/gabor.c	2006-11-15 07:50:31.000000000 -0600
+++ FeatureExtraction/gabor.c	2006-11-15 07:47:15.000000000 -0600
@@ -17,6 +17,8 @@
 
 static int kernal_size[num_gabor_scales] = {gabor_kernel_size_0, gabor_kernel_size_1, gabor_kernel_size_2};
 
+#define MAX_KERNAL_SIZE gabor_kernel_size_2
+
 void save_norm_double_pgm(double *double_im, int w, int h, char *fname) {
 
 	PPM *im;
@@ -89,7 +91,7 @@
 	double * target_kernal;
 	double * target_conv;
 	double * target_image;
-	double temparray[kernal_size[2]];
+	double temparray[MAX_KERNAL_SIZE];
 
 	/* first convolution */
 	target_kernal=kernelsxy[filter_scale*num_gabors_per_scale+orientation];
20-ChangeLog (text/plain, 547 B)
--- ../../dev3/gift/ChangeLog	2006-11-19 12:02:38.000000000 -0600
+++ ChangeLog	2006-11-19 12:02:31.000000000 -0600
@@ -47,6 +47,8 @@
 	fix an off-by-one error in the addressing of value_plane_double_reversed. my fault.
 	* FeatureExtraction/gabor.c
 	move from using an array to initialize the size of another array to using a define'd value. one less GCC warning, and slightly faster.
+	* libSquirePPM/ppm_comment.c
+	fix an off-by-one error in the allocation of ppm->comments. NOT my fault. finally! :)
 
 2006-10-10    <[email protected]>
20-libSquirePPM_ppm_comment_c-fix_pointer_error.patch (text/plain, 464 B)
--- ../../anoncvs/gift/libSquirePPM/ppm_comment.c	2001-02-01 12:22:41.000000000 +0100
+++ libSquirePPM/ppm_comment.c	2006-11-09 05:27:17.000000000 +0100
@@ -40,7 +40,7 @@
 		free(the_ppm->comments);
 
 	the_ppm->comment_length = i + strlen(new_comment);
-	the_ppm->comments = malloc(the_ppm->comment_length*sizeof(char));
+	the_ppm->comments = malloc((the_ppm->comment_length+1)*sizeof(char));
 	i = 0;
 	if (original_comments != NULL) {
 		c = original_comments;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.