Index: trunk/src/sh_files.c
===================================================================
--- trunk/src/sh_files.c	(revision 171)
+++ trunk/src/sh_files.c	(revision 227)
@@ -1489,9 +1489,9 @@
   int             status;
   int             dummy = S_FALSE;
-  dir_type        theDir;
+  dir_type      * theDir;
   ShFileType      checkit;
   static unsigned int state = 1;
 
-  file_type       theFile;
+  file_type     * theFile;
   char          * tmpname;
   char          * tmpcat;
@@ -1571,17 +1571,19 @@
   /* ---- stat the directory ----
    */
-  sl_strlcpy (theFile.fullpath, iname, PATH_MAX);
-  theFile.attr_string = NULL;
-  theFile.link_path   = NULL;
+  theFile = SH_ALLOC(sizeof(file_type));
+  sl_strlcpy (theFile->fullpath, iname, PATH_MAX);
+  theFile->attr_string = NULL;
+  theFile->link_path   = NULL;
 
   (void) relativeName;
   status = sh_unix_getinfo (ShDFLevel[SH_ERR_T_DIR], 
 			    iname,
-			    &theFile, NULL, iclass);
+			    theFile, NULL, iclass);
 
   if ((sig_termfast == 1) || (sig_terminate == 1)) 
     {
-      if (theFile.attr_string) SH_FREE(theFile.attr_string);
-      if (theFile.link_path)   SH_FREE(theFile.link_path);
+      if (theFile->attr_string) SH_FREE(theFile->attr_string);
+      if (theFile->link_path)   SH_FREE(theFile->link_path);
+      SH_FREE(theFile);
       SL_RETURN((0), _("sh_files_checkdir"));
     }
@@ -1590,10 +1592,11 @@
     {
       SH_FREE(tmpname); 
-      if (theFile.attr_string) SH_FREE(theFile.attr_string);
-      if (theFile.link_path)   SH_FREE(theFile.link_path);
-     SL_RETURN((-1), _("sh_files_checkdir"));
-    }
-
-  if (theFile.c_mode[0] != 'd') 
+      if (theFile->attr_string) SH_FREE(theFile->attr_string);
+      if (theFile->link_path)   SH_FREE(theFile->link_path);
+      SH_FREE(theFile);
+      SL_RETURN((-1), _("sh_files_checkdir"));
+    }
+
+  if (theFile->c_mode[0] != 'd') 
     { 
       sh_error_handle (ShDFLevel[SH_ERR_T_DIR], FIL__, __LINE__, 0,
@@ -1601,11 +1604,15 @@
 		       tmpname);
       SH_FREE(tmpname); 
-      if (theFile.attr_string) SH_FREE(theFile.attr_string);
-      if (theFile.link_path)   SH_FREE(theFile.link_path);
+      if (theFile->attr_string) SH_FREE(theFile->attr_string);
+      if (theFile->link_path)   SH_FREE(theFile->link_path);
+      SH_FREE(theFile);
       SL_RETURN((-1), _("sh_files_checkdir"));
     }
 
-  hardlink_num = theFile.hardlinks;
-
+  hardlink_num = theFile->hardlinks;
+
+  if (theFile->attr_string) SH_FREE(theFile->attr_string);
+  if (theFile->link_path)   SH_FREE(theFile->link_path);
+  SH_FREE(theFile);
 
   /* ---- open directory for reading ---- 
@@ -1623,22 +1630,21 @@
 		       sh_error_message (status, errbuf, sizeof(errbuf)), tmpname);
       SH_FREE(tmpname); 
-
-      if (theFile.attr_string) SH_FREE(theFile.attr_string);
-      if (theFile.link_path)   SH_FREE(theFile.link_path);
       SL_RETURN((-1), _("sh_files_checkdir"));
     }
 
-  theDir.NumRegular  = 0;
-  theDir.NumDirs     = 0;
-  theDir.NumSymlinks = 0;
-  theDir.NumFifos    = 0;
-  theDir.NumSockets  = 0;
-  theDir.NumCDev     = 0;
-  theDir.NumBDev     = 0;
-  theDir.NumDoor     = 0;
-  theDir.NumPort     = 0;
-  theDir.NumAll      = 0;
-  theDir.TotalBytes  = 0;
-  sl_strlcpy (theDir.DirPath, iname, PATH_MAX); 
+  theDir = SH_ALLOC(sizeof(dir_type));
+
+  theDir->NumRegular  = 0;
+  theDir->NumDirs     = 0;
+  theDir->NumSymlinks = 0;
+  theDir->NumFifos    = 0;
+  theDir->NumSockets  = 0;
+  theDir->NumCDev     = 0;
+  theDir->NumBDev     = 0;
+  theDir->NumDoor     = 0;
+  theDir->NumPort     = 0;
+  theDir->NumAll      = 0;
+  theDir->TotalBytes  = 0;
+  sl_strlcpy (theDir->DirPath, iname, PATH_MAX); 
 
 
@@ -1654,13 +1660,13 @@
       if (thisEntry != NULL) 
 	{
-	  ++theDir.NumAll;
+	  ++theDir->NumAll;
 	  if (sl_strcmp (thisEntry->d_name, ".") == 0)
 	    { 
-	      ++theDir.NumDirs;
+	      ++theDir->NumDirs;
 	      continue;
 	    }
 	  if (sl_strcmp (thisEntry->d_name, "..") == 0)
 	    {
-	      ++theDir.NumDirs;
+	      ++theDir->NumDirs;
 	      continue;
 	    }
@@ -1686,6 +1692,5 @@
     if (sig_termfast == 1) 
       {
-	if (theFile.attr_string) SH_FREE(theFile.attr_string);
-	if (theFile.link_path)   SH_FREE(theFile.link_path);
+	SH_FREE(theDir);
 	SL_RETURN((0), _("sh_files_checkdir"));
       }
@@ -1769,5 +1774,5 @@
 	if (checkit == SH_FILE_DIRECTORY) 
 	  {
-	    ++theDir.NumDirs;
+	    ++theDir->NumDirs;
 	  }
 	SH_FREE(tmpcat);
@@ -1805,9 +1810,9 @@
     
     if      (checkit == SH_FILE_REGULAR)   
-      ++theDir.NumRegular;
+      ++theDir->NumRegular;
     
     else if (checkit == SH_FILE_DIRECTORY) 
       {
-	++theDir.NumDirs;
+	++theDir->NumDirs;
 	if (rdepth_next >= 0 && cchecked_flag != S_TRUE) 
 	  {
@@ -1870,11 +1875,11 @@
       }
     
-    else if (checkit == SH_FILE_SYMLINK)   ++theDir.NumSymlinks;
-    else if (checkit == SH_FILE_FIFO)      ++theDir.NumFifos;
-    else if (checkit == SH_FILE_SOCKET)    ++theDir.NumSockets;
-    else if (checkit == SH_FILE_CDEV)      ++theDir.NumCDev;
-    else if (checkit == SH_FILE_BDEV)      ++theDir.NumBDev;
-    else if (checkit == SH_FILE_DOOR)      ++theDir.NumDoor;
-    else if (checkit == SH_FILE_PORT)      ++theDir.NumPort;
+    else if (checkit == SH_FILE_SYMLINK)   ++theDir->NumSymlinks;
+    else if (checkit == SH_FILE_FIFO)      ++theDir->NumFifos;
+    else if (checkit == SH_FILE_SOCKET)    ++theDir->NumSockets;
+    else if (checkit == SH_FILE_CDEV)      ++theDir->NumCDev;
+    else if (checkit == SH_FILE_BDEV)      ++theDir->NumBDev;
+    else if (checkit == SH_FILE_DOOR)      ++theDir->NumDoor;
+    else if (checkit == SH_FILE_PORT)      ++theDir->NumPort;
     
     SH_FREE(tmpcat);
@@ -1882,6 +1887,5 @@
     if ((sig_termfast == 1) || (sig_terminate == 1)) 
       {
-	if (theFile.attr_string) SH_FREE(theFile.attr_string);
-	if (theFile.link_path)   SH_FREE(theFile.link_path);
+	SH_FREE(theDir);
 	SL_RETURN((0), _("sh_files_checkdir"));
       }
@@ -1897,11 +1901,11 @@
     {
       sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_DSUM,
-		       theDir.NumDirs,
-		       theDir.NumRegular,
-		       theDir.NumSymlinks,
-		       theDir.NumFifos,
-		       theDir.NumSockets,
-		       theDir.NumCDev,
-		       theDir.NumBDev);
+		       theDir->NumDirs,
+		       theDir->NumRegular,
+		       theDir->NumSymlinks,
+		       theDir->NumFifos,
+		       theDir->NumSockets,
+		       theDir->NumCDev,
+		       theDir->NumBDev);
     }
 
@@ -1912,7 +1916,7 @@
    * Hardlink check; not done on MacOS X because of resource forks
    */
-  if ((sh_check_hardlinks == S_TRUE) && (hardlink_num != theDir.NumDirs)) 
-    {
-      if (0 != sh_files_hle_test(hardlink_num-theDir.NumDirs, iname))
+  if ((sh_check_hardlinks == S_TRUE) && (hardlink_num != theDir->NumDirs)) 
+    {
+      if (0 != sh_files_hle_test(hardlink_num-theDir->NumDirs, iname))
 	{
 	  len = strlen(tmpname);
@@ -1922,5 +1926,5 @@
 	  sl_snprintf(tmpcat, len, 
 		      _("%s: subdirectory count (%d) != hardlinks (%d)"),
-		      tmpname, theDir.NumDirs, hardlink_num);
+		      tmpname, theDir->NumDirs, hardlink_num);
 	  sh_error_handle (ShDFLevel[SH_ERR_T_DIR], FIL__, __LINE__, 0, 
 			   MSG_E_SUBGEN, tmpcat, _("sh_files_checkdir"));
@@ -1930,7 +1934,6 @@
 #endif
 
-  if (theFile.attr_string) SH_FREE(theFile.attr_string);
-  if (theFile.link_path)   SH_FREE(theFile.link_path);
   SH_FREE(tmpname);
+  SH_FREE(theDir);
 
   SL_RETURN((0), _("sh_files_checkdir"));
@@ -1947,8 +1950,8 @@
   /* 28 Aug 2001 allow NULL fileName
    */
-  char            fullpath[PATH_MAX];
+  char          * fullpath;
   char            fileHash[2*(KEY_LEN + 1)];
   int             status;
-  file_type       theFile;
+  file_type     * theFile;
   char          * tmpdir;
   char          * tmpname;
@@ -1956,6 +1959,10 @@
   struct utimbuf  utime_buf;
   static unsigned int state = 1;
+  char            sc;
 
   SL_ENTER(_("sh_files_filecheck"));
+
+  fullpath = SH_ALLOC(PATH_MAX);
+  theFile  = SH_ALLOC(sizeof(file_type));
 
   BREAKEXIT(sh_derr);
@@ -1982,4 +1989,6 @@
     {
       sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_NULL);
+      SH_FREE(fullpath);
+      SH_FREE(theFile);
       SL_RETURN(SH_FILE_UNKNOWN, _("sh_files_filecheck"));
     }
@@ -2020,4 +2029,6 @@
       SH_FREE(tmpname);
       SH_FREE(tmpdir);
+      SH_FREE(fullpath);
+      SH_FREE(theFile);
       SL_RETURN(SH_FILE_UNKNOWN, _("sh_files_filecheck"));
     } 
@@ -2026,9 +2037,9 @@
   /* stat the file and determine checksum (if a regular file)
    */
-  sl_strlcpy (theFile.fullpath, fullpath, PATH_MAX);
-  theFile.check_mask    = sh_files_maskof(class);
-  theFile.file_reported = (*reported);
-  theFile.attr_string   = NULL;
-  theFile.link_path     = NULL;
+  sl_strlcpy (theFile->fullpath, fullpath, PATH_MAX);
+  theFile->check_mask    = sh_files_maskof(class);
+  theFile->file_reported = (*reported);
+  theFile->attr_string   = NULL;
+  theFile->link_path     = NULL;
 
   TPT(( 0, FIL__, __LINE__, _("msg=<checking file: %s>\n"),  fullpath));
@@ -2037,5 +2048,5 @@
 			     ShDFLevel[class] : ShDFLevel[SH_ERR_T_FILE], 
 			     fileName,
-			     &theFile, fileHash, class);
+			     theFile, fileHash, class);
   
   if (status != 0)
@@ -2045,6 +2056,8 @@
       if (class == SH_LEVEL_ALLIGNORE && sh.flag.checkSum != SH_CHECK_INIT)
 	sh_hash_set_visited_true (fullpath);
-      if (theFile.attr_string) SH_FREE(theFile.attr_string);
-      if (theFile.link_path)   SH_FREE(theFile.link_path);
+      if (theFile->attr_string) SH_FREE(theFile->attr_string);
+      if (theFile->link_path)   SH_FREE(theFile->link_path);
+      SH_FREE(fullpath);
+      SH_FREE(theFile);
       SL_RETURN(SH_FILE_UNKNOWN, _("sh_files_filecheck"));
     }
@@ -2056,5 +2069,5 @@
   /* report
    */
-  if ((flag_err_debug == SL_TRUE) && (theFile.c_mode[0] == '-'))
+  if ((flag_err_debug == SL_TRUE) && (theFile->c_mode[0] == '-'))
     {
       tmpname = sh_util_safe_name (fullpath); /* fixed in 1.5.4 */
@@ -2067,5 +2080,5 @@
   if ( sh.flag.checkSum == SH_CHECK_INIT /* && sh.flag.update == S_FALSE */) 
     {
-      sh_hash_pushdata (&theFile, fileHash);
+      sh_hash_pushdata (theFile, fileHash);
     }
   else if (sh.flag.checkSum == SH_CHECK_CHECK 
@@ -2074,15 +2087,15 @@
 	   ) 
     {
-      sh_hash_compdata (class, &theFile, fileHash, NULL, -1);
+      sh_hash_compdata (class, theFile, fileHash, NULL, -1);
     }
   
-  (*reported) = theFile.file_reported;
+  (*reported) = theFile->file_reported;
 
   /* reset the access time 
    */
-  if (class == SH_LEVEL_NOIGNORE && (theFile.check_mask & MODI_ATM) != 0)
-    {
-      utime_buf.actime   = (time_t) theFile.atime;
-      utime_buf.modtime  = (time_t) theFile.mtime;
+  if (class == SH_LEVEL_NOIGNORE && (theFile->check_mask & MODI_ATM) != 0)
+    {
+      utime_buf.actime   = (time_t) theFile->atime;
+      utime_buf.modtime  = (time_t) theFile->mtime;
 #if !defined(O_NOATIME)
       retry_aud_utime (FIL__, __LINE__, fullpath, &utime_buf);
@@ -2094,10 +2107,10 @@
    * Check for resource fork
    */
-  if ( (theFile.c_mode[0] != 'd') && (rsrcflag == 0) )
+  if ( (theFile->c_mode[0] != 'd') && (rsrcflag == 0) )
     {
       int  dummy;
       static int rsrc_init = 0;
       static char rsrc[17];
-      char testpath[PATH_MAX];
+      char testpath = SH_ALLOC(PATH_MAX);
 
       if (rsrc_init == 0) {
@@ -2116,4 +2129,5 @@
 	    }
 	}
+      SH_FREE(testpath);
     }
 #else
@@ -2123,8 +2137,12 @@
  ret_point:
 
-  if (theFile.attr_string) SH_FREE(theFile.attr_string);
-  if (theFile.link_path)   SH_FREE(theFile.link_path);
-
-  switch (theFile.c_mode[0]) 
+  sc = theFile->c_mode[0];
+
+  if (theFile->attr_string) SH_FREE(theFile->attr_string);
+  if (theFile->link_path)   SH_FREE(theFile->link_path);
+  SH_FREE(fullpath);
+  SH_FREE(theFile);
+
+  switch (sc) 
     {
     case '-': SL_RETURN(SH_FILE_REGULAR, _("sh_files_filecheck"));   
