From 7610f76aea4497c8fef0a53a8116d43aac3d2234 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Mon, 6 Jul 2020 09:31:22 -0700 Subject: [PATCH] Remove another file_struct kluge. --- flist.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/flist.c b/flist.c index 21c0b31a..c17a5620 100644 --- 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 -- 2.47.2