nmh-workers
[Top] [All Lists]

patch to uip/folder.c

1995-07-14 17:07:49
Here's a patch to mh-6.8.3/uip/folder.c to fix the fact that
"folders -fast -recurse" doesn't process more than 300 folders.
I checked with "purify" that no memory leaks or faults occur .  (At least
not any new ones.)  Apply this patch in the mh-6.8.3 directory with a
command like:
show | patch -N

*** uip/folder.c.old    1995/07/10 18:53:01
--- uip/folder.c        1995/07/14 23:01:01
***************
*** 1,6 ****
  /* folder(s).c - report on folders */
  #ifndef       lint
! static char ident[] = "@(#)$Id: folder.c,v 2.11 1993/08/27 23:23:06 jromine 
Exp $";
  #endif        /* lint */

  #include "../h/mh.h"
--- 1,6 ----
  /* folder(s).c - report on folders */
  #ifndef       lint
! static char ident[] = "@(#)$Id: folder.c,v 2.12 1995/07/14 23:01:01 kelem Exp 
$";
  #endif        /* lint */

  #include "../h/mh.h"
***************
*** 91,97 ****
  static char *mhdir;
  static char *stack = "Folder-Stack";
  static char folder[BUFSIZ];
! static char *folds[NFOLDERS + 1];

  struct msgs *tfold ();

--- 91,98 ----
  static char *mhdir;
  static char *stack = "Folder-Stack";
  static char folder[BUFSIZ];
! static int nfolders = NFOLDERS;
! static char **folds;

  struct msgs *tfold ();

***************
*** 106,112 ****
              printsw = 0,
              listsw = 0,
              pushsw = 0,
!             popsw = 0;
      char   *cp,
             *dp,
             *msg = NULL,
--- 107,114 ----
              printsw = 0,
              listsw = 0,
              pushsw = 0,
!             popsw = 0,
!           i;
      char   *cp,
             *dp,
             *msg = NULL,
***************
*** 120,125 ****
--- 122,133 ----
  #ifdef LOCALE
        setlocale(LC_ALL, "");
  #endif
+     /* allocate an initial number of folders (NFOLDERS+1) */
+     if (! (folds = (char**)malloc((size_t)(nfolders +1)* sizeof(char *))))
+       adios (NULLCP, "Unable to initialize folders array", NFOLDERS);
+     for (i = 0; i < nfolders+1; i++) {
+       folds[i] = 0;
+     }
      invo_name = r1bindex (argv[0], '/');
      if (argv[0][strlen (argv[0]) - 1] == 's')
        all++;
***************
*** 358,363 ****
--- 366,374 ----
      }

      m_update ();
+     for (i=start; i <= nfolders; i++) {
+       if (folds[i]) {free (folds[i]);}
+     }

      done (0);
  }
***************
*** 580,588 ****
      register int    i,
                      j;
      register char  *cp;

!     if (foldp > NFOLDERS)
!       adios (NULLCP, "more than %d folders to report on", NFOLDERS);

      cp = getcpy (fold);
      for (i = start; i < foldp; i++)
--- 591,610 ----
      register int    i,
                      j;
      register char  *cp;
+     int resize;

!     if (foldp > nfolders) {
!       resize = nfolders*1.4;
! #ifdef DEBUG
!       printf("Resizing folds array from %d to %d\n", nfolders, resize);
! #endif
!       if (! (folds = (char**)realloc((char *)folds, (size_t)
!                                    ((nfolders=resize) +1)*sizeof(char *))))
!       adios (NULLCP, "Unable to resize folders array", nfolders);
!       for (i = foldp; i < nfolders+1; i++) {
!       folds[i] = 0;
!       }
!     }

      cp = getcpy (fold);
      for (i = start; i < foldp; i++)

/7\'7  Steve Kelem      (408)879-5347           
Steve(_dot_)Kelem(_at_)xilinx(_dot_)com
\\ `   Xilinx                                   FAX: (408)559-7114
//     2100 Logic Drive
\\/.\  San Jose, California 95124


<Prev in Thread] Current Thread [Next in Thread>
  • patch to uip/folder.c, Steve Kelem <=