[PATCH 099/194] object: allow grow_object_hash to handle arbitrary repositories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx>
---
 object.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/object.c b/object.c
index f518e5703b..be5d6c0931 100644
--- a/object.c
+++ b/object.c
@@ -115,27 +115,28 @@ struct object *lookup_object_the_repository(const unsigned char *sha1)
  * power of 2 (but at least 32).  Copy the existing values to the new
  * hash map.
  */
-#define grow_object_hash(r) grow_object_hash_##r()
-static void grow_object_hash_the_repository(void)
+static void grow_object_hash(struct repository *r)
 {
 	int i;
 	/*
 	 * Note that this size must always be power-of-2 to match hash_obj
 	 * above.
 	 */
-	int new_hash_size = the_repository->parsed_objects.obj_hash_size < 32 ? 32 : 2 * the_repository->parsed_objects.obj_hash_size;
+	int new_hash_size = r->parsed_objects.obj_hash_size < 32
+				? 32
+				: 2 * r->parsed_objects.obj_hash_size;
 	struct object **new_hash;
 
 	new_hash = xcalloc(new_hash_size, sizeof(struct object *));
-	for (i = 0; i < the_repository->parsed_objects.obj_hash_size; i++) {
-		struct object *obj = the_repository->parsed_objects.obj_hash[i];
+	for (i = 0; i < r->parsed_objects.obj_hash_size; i++) {
+		struct object *obj = r->parsed_objects.obj_hash[i];
 		if (!obj)
 			continue;
 		insert_obj_hash(obj, new_hash, new_hash_size);
 	}
-	free(the_repository->parsed_objects.obj_hash);
-	the_repository->parsed_objects.obj_hash = new_hash;
-	the_repository->parsed_objects.obj_hash_size = new_hash_size;
+	free(r->parsed_objects.obj_hash);
+	r->parsed_objects.obj_hash = new_hash;
+	r->parsed_objects.obj_hash_size = new_hash_size;
 }
 
 void *create_object_the_repository(const unsigned char *sha1, void *o)
-- 
2.15.1.433.g936d1b9894.dirty




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux