Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site oddjob.UChicago.UUCP Path: utzoo!watmath!clyde!burl!mgnetp!ihnp4!oddjob!matt From: matt@oddjob.UChicago.UUCP (Matt Crawford) Newsgroups: net.emacs Subject: emacs #264 can't do filename completion in big dirs. Message-ID: <286@oddjob.UChicago.UUCP> Date: Sun, 10-Jun-84 16:35:37 EDT Article-I.D.: oddjob.286 Posted: Sun Jun 10 16:35:37 1984 Date-Received: Mon, 11-Jun-84 00:42:36 EDT Organization: U. Chicago: Astronomy & Astrophysics Lines: 58 Index: filecomp.c FIX Description: If the total length of filenames in the directory you attempt completion in (excluding .o files, backups, etc) is more than about 1000 characters, filename completion does not work. If, in addition, there are over 50 files, you probably get a core dump. Repeat-By: Should be obvious. For me it happens in the emacs source directory. Fix: When a realloc() of the string space used to hold filenames is done the pointers in DirEnts[] must be updated to point to the new EntryNames[] space. If DirEnts[] is later realloc()'d it will wind up using some of the old EntryNames[] space. In this case, MarkDir() will be smashing bytes in DirEnts[]. The following change fixes the problem: o 3% diff -c filecomp.c.OLD filecomp.c *** filecomp.c.OLD --- filecomp.c *************** *** 181,188 EntryNameSize = (BytesUsed + p -> d_namlen) * 3 / 2; if (EntryNameSize < 1000) EntryNameSize = 1000; ! EntryNames = EntryNames ? (char *) realloc (EntryNames, EntryNameSize) ! : (char *) malloc (EntryNameSize); } if (DirUsed >= DirSize) { DirSize = DirUsed + 50; --- 181,201 ----- EntryNameSize = (BytesUsed + p -> d_namlen) * 3 / 2; if (EntryNameSize < 1000) EntryNameSize = 1000; ! if ( EntryNames ) { ! /* if we realloc() must update existing pointers in DirEnts */ ! register int offset; ! register char *oldptr = EntryNames; ! ! EntryNames = (char *) realloc (EntryNames, EntryNameSize); ! offset = EntryNames - oldptr; ! if ( offset ) { ! register int i; ! ! for ( i = 0; i < DirUsed; i++ ) ! DirEnts[i] += offset; ! } ! } else /* this is initial allocation */ ! EntryNames = (char *) malloc (EntryNameSize); } if (DirUsed >= DirSize) { DirSize = DirUsed + 50; ___________________________________________________________ Matt University ARPA: crawford@anl-mcs.arpa Crawford of Chicago UUCP: ihnp4!oddjob!matt