summaryrefslogtreecommitdiffstats
path: root/usr.bin/diff/diffdir.c
diff options
context:
space:
mode:
authorray <ray@openbsd.org>2007-05-29 18:24:56 +0000
committerray <ray@openbsd.org>2007-05-29 18:24:56 +0000
commit4a034c3afb52c73cfcf3b703742a2e85c07e470b (patch)
tree67fc6e5ca9d3858ff7255d66fc36de3435a289e8 /usr.bin/diff/diffdir.c
parentMove tokenring support to the attic where it can join the cards that where (diff)
downloadwireguard-openbsd-4a034c3afb52c73cfcf3b703742a2e85c07e470b.tar.xz
wireguard-openbsd-4a034c3afb52c73cfcf3b703742a2e85c07e470b.zip
Bring in some changes from rcsdiff:
1. Replace all the e*alloc functions with the x*alloc versions. 2. Whitespace syncs according to style. 3. Remove the __inline stuff. 4. Remove the min/max functions, using the MAX/MIN macros instead. OK millert@
Diffstat (limited to 'usr.bin/diff/diffdir.c')
-rw-r--r--usr.bin/diff/diffdir.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/usr.bin/diff/diffdir.c b/usr.bin/diff/diffdir.c
index 764cd9d535a..bd5a7fcca08 100644
--- a/usr.bin/diff/diffdir.c
+++ b/usr.bin/diff/diffdir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diffdir.c,v 1.30 2005/06/15 18:44:01 millert Exp $ */
+/* $OpenBSD: diffdir.c,v 1.31 2007/05/29 18:24:56 ray Exp $ */
/*
* Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -21,7 +21,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: diffdir.c,v 1.30 2005/06/15 18:44:01 millert Exp $";
+static const char rcsid[] = "$OpenBSD: diffdir.c,v 1.31 2007/05/29 18:24:56 ray Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -39,6 +39,7 @@ static const char rcsid[] = "$OpenBSD: diffdir.c,v 1.30 2005/06/15 18:44:01 mill
#include <unistd.h>
#include "diff.h"
+#include "xmalloc.h"
static int dircompare(const void *, const void *);
static int excluded(const char *);
@@ -146,12 +147,12 @@ diffdir(char *p1, char *p2)
}
if (dirbuf1 != NULL) {
- free(dirp1);
- free(dirbuf1);
+ xfree(dirp1);
+ xfree(dirbuf1);
}
if (dirbuf2 != NULL) {
- free(dirp2);
- free(dirbuf2);
+ xfree(dirp2);
+ xfree(dirbuf2);
}
}
@@ -190,20 +191,20 @@ slurpdir(char *path, char **bufp, int enoentok)
need = roundup(sb.st_blksize, sizeof(struct dirent));
have = bufsize = roundup(MAX(sb.st_size, sb.st_blksize),
sizeof(struct dirent)) + need;
- ebuf = buf = emalloc(bufsize);
+ ebuf = buf = xmalloc(bufsize);
do {
if (have < need) {
bufsize += need;
have += need;
- cp = erealloc(buf, bufsize);
+ cp = xrealloc(buf, 1, bufsize);
ebuf = cp + (ebuf - buf);
buf = cp;
}
nbytes = getdirentries(fd, ebuf, have, &base);
if (nbytes == -1) {
warn("%s", path);
- free(buf);
+ xfree(buf);
close(fd);
return (NULL);
}
@@ -225,7 +226,7 @@ slurpdir(char *path, char **bufp, int enoentok)
break;
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; ) {
dp = (struct dirent *)cp;
if (dp->d_fileno != 0 && !excluded(dp->d_name)) {