threads / patch / 212

patch, 19 partsMigrate update-cache.c to use the new cache api's

Subject: [PATCH 04/19] Migrate update-cache.c to use the new cache api's

## tl;dr

One message between Apr 21, 2005 and Apr 21, 2005. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Brad Roberts· Apr 21, 2005, 18:35 UTC · lore

tree 34f7fc89e28a40387e811057065592ed2f0218a2 parent d70686e08f453199e5451b27fc7d0b36b73a5c7f author Brad Roberts <braddr@puremagic.com> 1114073784 -0700 committer Brad Roberts <braddr@gameboy2.puremagic.com> 1114073784 -0700

[PATCH] Migrate update-cache.c to use the new cache api's
Signed-off-by: Brad Roberts <braddr@puremagic.com>
---
 read-cache.c   |    3 +++
 update-cache.c |   13 +++++--------
 2 files changed, 8 insertions(+), 8 deletions(-)
Show changes to diff +8 −8
Index: read-cache.c
===================================================================
--- d70686e08f453199e5451b27fc7d0b36b73a5c7f:1/read-cache.c  (mode:100644 sha1:6689df59d5a93e0503d7c80c114efbd16de826f3)
+++ 40bf732f5bcb986943070a2ed6c09a16543d81be:1/read-cache.c  (mode:100644 sha1:8eaa05957a481b09116c37e43e16c5ef4e219a1e)
@@ -122,6 +122,9 @@
 
 void set_cache_entry(struct cache_entry *ce, int pos)
 {
+	/* You can NOT just free active_cache[i] here, since it
+	 * might not be necessarily malloc()ed but can also come
+	 * from mmap(). */
 	active_cache[pos] = ce;
 }
 
Index: update-cache.c
===================================================================
--- d70686e08f453199e5451b27fc7d0b36b73a5c7f:1/update-cache.c  (mode:100644 sha1:585951108c57a64bb774114d289d81fd7fd22768)
+++ 40bf732f5bcb986943070a2ed6c09a16543d81be:1/update-cache.c  (mode:100644 sha1:e741f593eb9c56c596fabed7eb6b79dee2d8cba9)
@@ -204,13 +204,13 @@
 {
 	int i;
 
-	for (i = 0; i < active_nr; i++) {
+	for (i = 0; i < get_num_cache_entries(); i++) {
 		struct cache_entry *ce, *new;
-		ce = active_cache[i];
+		ce = get_cache_entry(i);
 		if (ce_stage(ce)) {
 			printf("%s: needs merge\n", ce->name);
-			while ((i < active_nr) &&
-			       ! strcmp(active_cache[i]->name, ce->name))
+			while ((i < get_num_cache_entries()) &&
+			       ! strcmp(get_cache_entry(i)->name, ce->name))
 				i++;
 			i--;
 			continue;
@@ -221,10 +221,7 @@
 			printf("%s: needs update\n", ce->name);
 			continue;
 		}
-		/* You can NOT just free active_cache[i] here, since it
-		 * might not be necessarily malloc()ed but can also come
-		 * from mmap(). */
-		active_cache[i] = new;
+		set_cache_entry(new, i);
 	}
 }
 

← back to recent threads