[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Eliminate the static variable
From: |
Alexey Mahotkin |
Subject: |
[PATCH] Eliminate the static variable |
Date: |
Sun, 23 Sep 2001 02:17:35 +0400 (MSD) |
I was looking at the Find_Names() function and noticed that we could
get rid of "static filelist" variable, using the standard 'closure'
mechanism. Here is the patch:
2001-09-23 Alexey Mahotkin <alexm@hsys.msk.ru>
* find_names.c (Find_Names): Use 'closure' feature of walklist()
to eliminate the static variable.
Index: find_names.c
===================================================================
RCS file: /usr/local/tigris/data/helm/cvs/repository/ccvs/src/find_names.c,v
retrieving revision 1.29
diff -u -r1.29 find_names.c
--- find_names.c 2001/02/06 15:29:43 1.29
+++ find_names.c 2001/09/22 22:17:10
@@ -24,16 +24,14 @@
static int add_subdir_proc PROTO((Node *, void *));
static int register_subdir_proc PROTO((Node *, void *));
-static List *filelist;
-
/*
* add the key from entry on entries list to the files list
*/
static int add_entries_proc PROTO((Node *, void *));
static int
-add_entries_proc (node, closure)
+add_entries_proc (node, files)
Node *node;
- void *closure;
+ void *files;
{
Entnode *entnode;
Node *fnode;
@@ -45,7 +43,7 @@
fnode = getnode ();
fnode->type = FILES;
fnode->key = xstrdup (node->key);
- if (addnode (filelist, fnode) != 0)
+ if (addnode ((List *) files, fnode) != 0)
freenode (fnode);
return (0);
}
@@ -66,7 +64,7 @@
List *files;
/* make a list for the files */
- files = filelist = getlist ();
+ files = getlist ();
/* look at entries (if necessary) */
if (which & W_LOCAL)
@@ -76,7 +74,7 @@
if (entries != NULL)
{
/* walk the entries file adding elements to the files list */
- (void) walklist (entries, add_entries_proc, NULL);
+ (void) walklist (entries, add_entries_proc, files);
/* if our caller wanted the entries list, return it; else free it */
if (optentries != NULL)
--alexm
- [PATCH] Eliminate the static variable,
Alexey Mahotkin <=