+static FileEntry* NewFileEntry (const char* Name, unsigned long Size, unsigned long MTime)
+/* Create a new FileEntry, insert it into the tables and return it */
+{
+ /* Get the length of the name */
+ unsigned Len = strlen (Name);
+
+ /* Get the hash over the name */
+ unsigned Hash = HashStr (Name) % HASHTAB_SIZE;
+
+ /* Allocate memory for the entry */
+ FileEntry* F = xmalloc (sizeof (FileEntry) + Len);
+
+ /* Initialize the fields */
+ F->Index = FileCount+1;
+ F->Size = Size;
+ F->MTime = MTime;
+ memcpy (F->Name, Name, Len+1);
+
+ /* Count the entries and grow the file table if needed */
+ if (FileCount >= FileMax) {
+ /* We need to grow the table. Create a new one. */
+ unsigned NewFileMax = (FileMax == 0)? 32 : FileMax * 2;
+ FileEntry** NewFileTab = xmalloc (sizeof (FileEntry*) * NewFileMax);
+
+ /* Copy the old entries */
+ memcpy (NewFileTab, FileTab, sizeof (FileEntry*) * FileCount);
+
+ /* Use the new table */
+ xfree (FileTab);
+ FileTab = NewFileTab;
+ FileMax = NewFileMax;
+ }
+
+ /* Insert the file into the file table */
+ FileTab [FileCount++] = F;
+
+ /* Insert the entry into the hash table */
+ F->Next = HashTab[Hash];
+ HashTab[Hash] = F;
+
+ /* Return the new entry */
+ return F;
+}
+
+
+