Move index-related variables into a structure.
This defines a index_state structure and moves index-related global variables into it. Currently there is one instance of it, the_index, and everybody accesses it, so there is no code change. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Apr 1, 2007 at 18:14 UTC
228e94f93570b580da388069900c56b813c91953
2 files changed
+20
-11
cache.h
+16
-3
@@ -143,9 +143,22 @@ static inline unsigned int ce_mode_from_stat(struct cache_entry *ce, unsigned in
143
144
#define cache_entry_size(len) ((offsetof(struct cache_entry,name) + (len) + 8) & ~7)
145
146
-extern struct cache_entry **active_cache;
147
-extern unsigned int active_nr, active_alloc, active_cache_changed;
148
-extern struct cache_tree *active_cache_tree;
146
+struct index_state {
147
+ struct cache_entry **cache;
148
+ unsigned int cache_nr, cache_alloc, cache_changed;
149
+ struct cache_tree *cache_tree;
150
+ time_t timestamp;
151
+ void *mmap;
152
+ size_t mmap_size;
153
+};
154
+
155
+extern struct index_state the_index;
156
+
157
+#define active_cache (the_index.cache)
158
+#define active_nr (the_index.cache_nr)
159
+#define active_alloc (the_index.cache_alloc)
160
+#define active_cache_changed (the_index.cache_changed)
161
+#define active_cache_tree (the_index.cache_tree)
162
163
enum object_type {
164
OBJ_BAD = -1,
read-cache.c
+4
-8
@@ -19,14 +19,10 @@
19
#define CACHE_EXT(s) ( (s[0]<<24)|(s[1]<<16)|(s[2]<<8)|(s[3]) )
20
#define CACHE_EXT_TREE 0x54524545 /* "TREE" */
21
22
-struct cache_entry **active_cache;
23
-static time_t index_file_timestamp;
24
-unsigned int active_nr, active_alloc, active_cache_changed;
25
-
26
-struct cache_tree *active_cache_tree;
27
-
28
-static void *cache_mmap;
29
-static size_t cache_mmap_size;
22
+struct index_state the_index;
23
+#define index_file_timestamp (the_index.timestamp)
24
+#define cache_mmap (the_index.mmap)
25
+#define cache_mmap_size (the_index.mmap_size)
26
27
/*
28
* This only updates the "non-critical" parts of the directory