O.K. - here you go:
--- mustek.c.orig	Fri Oct 30 07:56:12 1998
+++ mustek.c	Tue Aug  3 21:27:28 1999
@@ -1767,6 +1767,9 @@
 	 the green buffer must be able to hold up to 1*dy lines. */
       s->ld.buf[RED] = malloc (3 * dy * (long) bpc);
       s->ld.buf[GRN] = s->ld.buf[RED] + 2 * dy * bpc;
+      memset(s->ld.buf[RED], 0, 3 * dy * (long) bpc);
+
+      DBG(2, "fix_line_distance_mfs: malloc and clear. \n");
     }
 
   /* restore the red and green lines from the previous buffer: */
@@ -1833,19 +1836,19 @@
   /* save red and green lines: */
   for (y = 0; y < 2*dy; ++y)
     {
-      if (num_lines - 2*dy + y >= 0)
+      if (num_lines + y >= 2*dy)
 	src = raw + (num_lines - 2*dy + y)*bpl;
-      else
+      else 
 	src = s->ld.buf[RED] + (y + num_lines)*bpc;
-      memcpy (s->ld.buf[RED] + y*bpc, src, bpc);
+      memmove (s->ld.buf[RED] + y*bpc, src, bpc);
     }
   for (y = 0; y < 1*dy; ++y)
     {
-      if (num_lines - 1*dy + y >= 0)
+      if (num_lines + y >= 1*dy)
 	src = raw + (num_lines - 1*dy + y)*bpl + bpc;
       else
 	src = s->ld.buf[GRN] + (y + num_lines)*bpc;
-      memcpy (s->ld.buf[GRN] + y*bpc, src, bpc);
+      memmove (s->ld.buf[GRN] + y*bpc, src, bpc);
     }
 }
 
And NO: The patch is not a NOP. 
The memset is just more clean and doesn't leave you with garbage in the 
top few lines (which are wrong anyway due to the lack of correction data). 
The memcpy->memmove is not required and should probably not be applied for 
the final version. It's a relic from testing.
The important one is the rephrasing of the arithmetics. Though both
expressions are mathematically equivalent, they are not in C, as there is a
subtle problem with automatic type promotion.
CU, ANdy
-- = Andreas Beck | Email : <andreas.beck@ggi-project.org> =
-- Source code, list archive, and docs: http://www.mostang.com/sane/ To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com