Index: trunk/src/sh_tiger0.c
===================================================================
--- trunk/src/sh_tiger0.c	(revision 1)
+++ trunk/src/sh_tiger0.c	(revision 8)
@@ -95,4 +95,5 @@
 SL_TICKET tiger_fd = (-1);
 
+static sh_byte buffer[PRIV_MAX + 72];
 
 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
@@ -108,11 +109,13 @@
 {
   SL_TICKET  fd;
-  int  i, j;
+  int  i, j, tt;
   int  count = 0;
   int  blk;
   char    * tmp;
   sh_byte * bptr;
-  sh_byte buffer[PRIV_MAX + 72];
+  /* sh_byte buffer[PRIV_MAX + 72]; */
   sh_byte bbuf[64];
+
+  static int lockflag = SL_FALSE;
 
   unsigned long pages_read;
@@ -148,16 +151,16 @@
   SL_ENTER(_("sh_tiger_hash_val"));
 
-  if (what == TIGER_FILE || what == TIGER_FD) 
-    {
-      if (what == TIGER_FILE)
+  if (what == TIGER_FD || what == TIGER_FILE) 
+    {
+      if (what == TIGER_FD)
+	{
+	  fd = tiger_fd;
+	  TPT((0,FIL__, __LINE__, _("msg=<TIGER_FD>, fd=<%ld>\n"), tiger_fd));
+	}
+      else
 	{
 	  TPT((0,FIL__, __LINE__, _("msg=<TIGER_FILE>, path=<%s>\n"),
 	       (filename == NULL ? _("(null)") : filename) ));
 	  fd = sl_open_read (filename, SL_YESPRIV);
-	}
-      else
-	{
-	  fd = tiger_fd;
-	  TPT((0,FIL__, __LINE__, _("msg=<TIGER_FD>, fd=<%ld>\n"), tiger_fd));
 	}
 
@@ -174,12 +177,16 @@
       
 #if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK)
-    if (skey->mlock_failed == SL_FALSE) 
+    if (lockflag == SL_FALSE && skey->mlock_failed == SL_FALSE) 
       {
         if ( (-1) == sh_unix_mlock((char *)buffer,(PRIV_MAX)*sizeof(sh_byte))) 
           skey->mlock_failed = SL_TRUE;
+	lockflag = SL_TRUE;
       }
 #else
-    if (skey->mlock_failed == SL_FALSE)
-      skey->mlock_failed = SL_TRUE;
+    if (lockflag == SL_FALSE && skey->mlock_failed == SL_FALSE)
+      {
+	skey->mlock_failed = SL_TRUE;
+	lockflag = SL_TRUE;
+      }
 #endif
 
@@ -190,5 +197,5 @@
     pages_read = 0;
 
-    while (1 == 1) 
+    while (1) 
       {
 	if (timeout > 0)
@@ -217,9 +224,9 @@
 			       count, MSG_E_READ, tmp);
 	    SH_FREE(tmp);
-	    (void) sh_unix_munlock((char*)buffer, (PRIV_MAX)*sizeof(sh_byte));
+	    memset (bbuf,   0, 64);
+	    memset (buffer, 0, PRIV_MAX);
+
 	    SL_RETURN( NULL, _("sh_tiger_hash_val"));
 	  }
-
-	/* TPT((0, FIL__, __LINE__ , _("msg=<Read %ld bytes>\n"), count)); */
 
 	blk      = (count / 64); /* number of 64-byte words */
@@ -228,14 +235,17 @@
 	 * count cannot be negative here, see 'if (SL_ISERROR (count))'
 	 */
-	ncount = (unsigned long) (count - ((count/64)*64));
+	tt = blk*64;
+
+	ncount = (unsigned long) (count - tt);
+
+	nblocks += blk;
+	sh.statistics.bytes_hashed += tt;
 	
-	bptr = buffer;
+	bptr = buffer; tt = 0;
 	for (i = 0; i < blk; ++i)
 	  {
-	    bptr = &buffer[64 * i];
+	    bptr = &buffer[tt]; tt += 64;
 	    
 	    tiger_t(TIGER_CAST bptr, 64, res);
-	    ++nblocks;
-	    sh.statistics.bytes_hashed += 64;
 	    
 #ifdef TIGER_DBG
@@ -252,6 +262,5 @@
 	    memset (bbuf,   0, 64);
 	    memset (buffer, 0, PRIV_MAX);
-	    (void) sh_unix_munlock( (char *) buffer, 
-				    (PRIV_MAX) * sizeof(sh_byte));
+
 	    SL_RETURN( NULL, _("sh_tiger_hash_val"));
 	  }
@@ -268,6 +277,12 @@
     /* copy incomplete block
      */
-    j = 0; for (i = 0; i < 64; ++i) 
-      bbuf[i] = (sh_byte) '\0';
+    j = 0; 
+    for (i = 0; i < 64; i += 4) 
+      {
+	bbuf[i]   = (sh_byte) '\0';
+	bbuf[i+1] = (sh_byte) '\0';
+	bbuf[i+2] = (sh_byte) '\0';
+	bbuf[i+3] = (sh_byte) '\0';
+      }
     for (i = (count/64) * 64; i < count; ++i)
       /*@-usedef@*/bbuf[j++] = buffer[i];/*@+usedef@*/
@@ -304,5 +319,12 @@
 	sh.statistics.bytes_hashed += 64;
 	++nblocks; ncount = 0;
-        memset(bbuf, 0, 56 ); 
+	for (i = 0; i < 56; i += 4) 
+	  {
+	    bbuf[i]   = (sh_byte) '\0';
+	    bbuf[i+1] = (sh_byte) '\0';
+	    bbuf[i+2] = (sh_byte) '\0';
+	    bbuf[i+3] = (sh_byte) '\0';
+	  }
+        /* memset(bbuf, 0, 56 ); */ 
       }
 
@@ -327,8 +349,21 @@
 #endif
 
-    memset (bbuf,   0, 64);
-    memset (buffer, 0, PRIV_MAX);
-
-    (void) sh_unix_munlock( (char *) buffer, (PRIV_MAX) * sizeof(sh_byte));
+    for (i = 0; i < 64; i += 4) 
+      {
+	bbuf[i]   = (sh_byte) '\0';
+	bbuf[i+1] = (sh_byte) '\0';
+	bbuf[i+2] = (sh_byte) '\0';
+	bbuf[i+3] = (sh_byte) '\0';
+      }
+
+    bptr = buffer;
+
+    memcpy(bptr, bbuf,    64); bptr +=   64;
+    memcpy(bptr, bbuf,    64); bptr +=   64;
+    memcpy(bptr, buffer, 128); bptr +=  128;
+    memcpy(bptr, buffer, 256); bptr +=  256;
+    memcpy(bptr, buffer, 512); bptr +=  512;
+    memcpy(bptr, buffer,1024); bptr += 1024;
+    memcpy(bptr, buffer,2048);
 
     if (what == TIGER_FILE)
@@ -343,5 +378,4 @@
   if (what == TIGER_DATA && filename != NULL) 
     {
-      /* TPT((0, FIL__, __LINE__, _("msg=<TIGER_DATA>\n"))); */
       tiger(TIGER_CAST filename,  (sh_word32) Length, res); 
       SL_RETURN(res, _("sh_tiger_hash_val"));
@@ -1158,5 +1192,5 @@
   SL_TICKET  fd;
   char * tmp;
-  uid_t   euid;
+  uid_t  euid;
 
   unsigned long pages_read;
