[GRASS5] segment lib speed patch

Markus Neteler neteler at itc.it
Mon Jun 27 11:03:56 EDT 2005


Hi,

to speed up the creation of segments in lib/segment/format.c,
a colleague from ITC-irst proposes the attached patch.
I used it locally for quite a while without having problems.

I would like to hear you opinion:
- any objections to include it (removing the old version)?
- should it be conditionalized for GNU/Linux only or
  anything else (means: modifying the current condition ORIG)?

Thanks

 Markus

-------------- next part --------------
Index: format.c
===================================================================
RCS file: /grassrepository/grass6/lib/segment/format.c,v
retrieving revision 2.0
diff -u -r2.0 format.c
--- format.c	9 Nov 2004 13:09:30 -0000	2.0
+++ format.c	27 Jun 2005 15:00:31 -0000
@@ -113,6 +113,7 @@
 
 static int zero_fill(int fd, long nbytes)
 {
+#ifdef ORIG
     char buf[10240];
     register char *b;
     register int n;
@@ -133,4 +134,19 @@
 	nbytes -= n;
     }
     return 1;
+#else
+    char buf[10];
+
+    buf[0]=0x0;
+    G_debug(3,"Using new segmentation code...");
+    if ( lseek(fd,nbytes-1,SEEK_SET) < 0 ) { 
+            G_warning("%s\n",strerror(errno));
+	    return -1;
+    }
+    if(write (fd,buf, 1) != 1) {
+            G_warning("%s\n",strerror(errno));
+	    return -1;
+    }
+    return 1;
+#endif
 }


More information about the grass-dev mailing list