Remove another file_struct kluge.
[rsync.git] / flist.c
diff --git a/flist.c b/flist.c
index 21c0b31a0d2ed47936c7f9d81d8ace645215fbd7..c17a5620d704ac70c9e7e2ec3fbfda92d7e3132a 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -2727,28 +2727,28 @@ int flist_find(struct file_list *flist, struct file_struct *f)
  * 1=match directories, 0=match non-directories, or -1=match either. */
 int flist_find_name(struct file_list *flist, const char *fname, int want_dir_match)
 {
-       struct { /* We have to create a temporary file_struct for the search. */
-               struct file_struct f;
-               char name_space[MAXPATHLEN];
-       } t;
+       static struct file_struct *f;
        char fbuf[MAXPATHLEN];
        const char *slash = strrchr(fname, '/');
        const char *basename = slash ? slash+1 : fname;
 
-       memset(&t.f, 0, FILE_STRUCT_LEN);
-       memcpy((void *)t.f.basename, basename, strlen(basename)+1);
+       if (!f)
+               f = (struct file_struct*)new_array(char, FILE_STRUCT_LEN + MAXPATHLEN + 1);
+
+       memset(f, 0, FILE_STRUCT_LEN);
+       memcpy((void*)f->basename, basename, strlen(basename)+1);
 
        if (slash) {
                strlcpy(fbuf, fname, slash - fname + 1);
-               t.f.dirname = fbuf;
+               f->dirname = fbuf;
        } else
-               t.f.dirname = NULL;
+               f->dirname = NULL;
 
-       t.f.mode = want_dir_match > 0 ? S_IFDIR : S_IFREG;
+       f->mode = want_dir_match > 0 ? S_IFDIR : S_IFREG;
 
        if (want_dir_match < 0)
-               return flist_find_ignore_dirness(flist, &t.f);
-       return flist_find(flist, &t.f);
+               return flist_find_ignore_dirness(flist, f);
+       return flist_find(flist, f);
 }
 
 /* Search for an identically-named item in the file list.  Differs from