about summary refs log tree commit diff
path: root/dirent/scandir.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-03-20 12:06:55 +0000
committerUlrich Drepper <drepper@redhat.com>1998-03-20 12:06:55 +0000
commit89a9e37b7a7a2134cedb6d27db265a8ab774f9d1 (patch)
tree19131b4a9aa63f7737c683a57a00b1b37bf7b701 /dirent/scandir.c
parent9c1a1da9866c22c1626f2222cf5d03ef1b0ede3b (diff)
downloadglibc-89a9e37b7a7a2134cedb6d27db265a8ab774f9d1.tar.gz
glibc-89a9e37b7a7a2134cedb6d27db265a8ab774f9d1.tar.xz
glibc-89a9e37b7a7a2134cedb6d27db265a8ab774f9d1.zip
Update.
1998-03-20 11:58  Ulrich Drepper  <drepper@cygnus.com>

	* dirent/Makefile (routines): Add scandir64, alphasort64, and
	versionsort64.
	* dirent/alphasort64.c: New file.
	* dirent/scandir64.c: New file.
	* dirent/versionsort64.c: New file.
	* dirent/dirent.h: Add LFS support for scandir, alphasort, and
	versionsort.
	* sysdeps/generic/readdir64.c: Rename to __readdir64 and make
	old name weak alias.
	* sysdeps/unix/sysv/linux/readdir64.c: Likewise.

	* dirent/alphasort.c: Use strcoll instead of strcmp.

	* dirent/scandir.c: Optimize a bit.

	* dirent/versionsort.c: Pretty print.

1998-03-20  Ulrich Drepper  <drepper@cygnus.com>

	* string/string.h: Add prototype for __strtok_r.
Diffstat (limited to 'dirent/scandir.c')
-rw-r--r--dirent/scandir.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/dirent/scandir.c b/dirent/scandir.c
index ef7531fa95..cffc8a98cb 100644
--- a/dirent/scandir.c
+++ b/dirent/scandir.c
@@ -44,6 +44,7 @@ scandir (dir, namelist, select, cmp)
   while ((d = __readdir (dp)) != NULL)
     if (select == NULL || (*select) (d))
       {
+	struct dirent *vnew;
 	size_t dsize;
 
 	/* Ignore errors from select or readdir */
@@ -58,20 +59,16 @@ scandir (dir, namelist, select, cmp)
 	      vsize *= 2;
 	    new = (struct dirent **) realloc (v, vsize * sizeof (*v));
 	    if (new == NULL)
-	      {
-	      lose:
-		__set_errno (ENOMEM);
-		break;
-	      }
+	      break;
 	    v = new;
 	  }
 
 	dsize = &d->d_name[_D_ALLOC_NAMLEN (d)] - (char *) d;
-	v[i] = (struct dirent *) malloc (dsize);
-	if (v[i] == NULL)
-	  goto lose;
+	vnew = (struct dirent *) malloc (dsize);
+	if (vnew == NULL)
+	  break;
 
-	memcpy (v[i++], d, dsize);
+	v[i++] = (struct dirent *) memcpy (vnew, d, dsize);
       }
 
   if (errno != 0)