Index: mk_jpgs.c
===================================================================
--- mk_jpgs.c	(revision 1107)
+++ mk_jpgs.c	(revision 1108)
@@ -45,15 +45,15 @@
 	struct stat stb;
 	long arraysz;
 	DIR *dirp;
+	int n;
 
 	if ((dirp = opendir(dirname)) == NULL)
 		return(-1);
 
-	/*
-	 * estimate the array size by taking the size of the directory file
-	 * and dividing it by a multiple of the minimum size entry. 
-	 */
-	arraysz = (stb.st_size / 24);
+	n=0;
+	while ((d=readdir(dirp)) !=NULL) n++;
+	rewinddir(dirp);
+	arraysz = (n);
 	names = (struct dirent **)malloc(arraysz * sizeof(struct dirent *));
 	if (names == NULL)
 		return(-1);