scandir.c.patch   [plain text]


--- scandir.c.orig	2009-11-07 14:51:38.000000000 -0800
+++ scandir.c	2009-11-07 14:51:40.000000000 -0800
@@ -47,15 +47,11 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/sca
 #include "un-namespace.h"
 
 /*
- * The DIRSIZ macro is the minimum record length which will hold the directory
+ * The _GENERIC_DIRSIZ macro is the minimum record length which will hold the directory
  * entry.  This requires the amount of space in struct dirent without the
  * d_name field, plus enough space for the name and a terminating nul byte
  * (dp->d_namlen + 1), rounded up to a 4 byte boundary.
  */
-#undef DIRSIZ
-#define DIRSIZ(dp)							\
-	((sizeof(struct dirent) - sizeof(dp)->d_name) +			\
-	    (((dp)->d_namlen + 1 + 3) &~ 3))
 
 int
 scandir(dirname, namelist, select, dcomp)
@@ -83,7 +79,7 @@ scandir(dirname, namelist, select, dcomp
 		/*
 		 * Make a minimum size copy of the data
 		 */
-		p = (struct dirent *)malloc(DIRSIZ(d));
+		p = (struct dirent *)malloc(_GENERIC_DIRSIZ(d));
 		if (p == NULL)
 			goto fail;
 		p->d_fileno = d->d_fileno;