[BACK]Return to diffdir.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / diff

Diff for /src/usr.bin/diff/diffdir.c between version 1.30 and 1.31

version 1.30, 2005/06/15 18:44:01 version 1.31, 2007/05/29 18:24:56
Line 39 
Line 39 
 #include <unistd.h>  #include <unistd.h>
   
 #include "diff.h"  #include "diff.h"
   #include "xmalloc.h"
   
 static int dircompare(const void *, const void *);  static int dircompare(const void *, const void *);
 static int excluded(const char *);  static int excluded(const char *);
Line 146 
Line 147 
         }          }
   
         if (dirbuf1 != NULL) {          if (dirbuf1 != NULL) {
                 free(dirp1);                  xfree(dirp1);
                 free(dirbuf1);                  xfree(dirbuf1);
         }          }
         if (dirbuf2 != NULL) {          if (dirbuf2 != NULL) {
                 free(dirp2);                  xfree(dirp2);
                 free(dirbuf2);                  xfree(dirbuf2);
         }          }
 }  }
   
Line 190 
Line 191 
         need = roundup(sb.st_blksize, sizeof(struct dirent));          need = roundup(sb.st_blksize, sizeof(struct dirent));
         have = bufsize = roundup(MAX(sb.st_size, sb.st_blksize),          have = bufsize = roundup(MAX(sb.st_size, sb.st_blksize),
             sizeof(struct dirent)) + need;              sizeof(struct dirent)) + need;
         ebuf = buf = emalloc(bufsize);          ebuf = buf = xmalloc(bufsize);
   
         do {          do {
                 if (have < need) {                  if (have < need) {
                     bufsize += need;                      bufsize += need;
                     have += need;                      have += need;
                     cp = erealloc(buf, bufsize);                      cp = xrealloc(buf, 1, bufsize);
                     ebuf = cp + (ebuf - buf);                      ebuf = cp + (ebuf - buf);
                     buf = cp;                      buf = cp;
                 }                  }
                 nbytes = getdirentries(fd, ebuf, have, &base);                  nbytes = getdirentries(fd, ebuf, have, &base);
                 if (nbytes == -1) {                  if (nbytes == -1) {
                         warn("%s", path);                          warn("%s", path);
                         free(buf);                          xfree(buf);
                         close(fd);                          close(fd);
                         return (NULL);                          return (NULL);
                 }                  }
Line 225 
Line 226 
                         break;                          break;
                 cp += dp->d_reclen;                  cp += dp->d_reclen;
         }          }
         dirlist = emalloc(sizeof(struct dirent *) * (entries + 1));          dirlist = xmalloc(sizeof(struct dirent *) * (entries + 1));
         for (entries = 0, cp = buf; cp < ebuf; ) {          for (entries = 0, cp = buf; cp < ebuf; ) {
                 dp = (struct dirent *)cp;                  dp = (struct dirent *)cp;
                 if (dp->d_fileno != 0 && !excluded(dp->d_name)) {                  if (dp->d_fileno != 0 && !excluded(dp->d_name)) {

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31