git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Odd behavior with git and cairo-devel repo

From
Linus Torvalds <torvalds@osdl.org>
Date
Jun 21, 2006, 18:01 UTC
Message-ID
<Pine.LNX.4.64.0606211054500.5498@g5.osdl.org>
In-Reply-To
<20060621174632.GP11245@skl-net.de>
On Wed, 21 Jun 2006, Andre Noll wrote:
>
> Fix grow_refs_hash()
Ouch. 

Actually, the alternate patch is the one I had intended to do but for some reasons didn't.

This one also removes two more lines than it adds, but it's obviously a bigger patch.

Junio, depending on which one you prefer, add the appropriate
	Acked-by: Linus Torvalds <torvalds@osdl.org>
(for Andre's one) or
	Signed-off-by: Linus Torvalds <torvalds@osdl.org>
if you take this one.
		Linus
---
 object-refs.c |   30 ++++++++++++++----------------
 1 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/object-refs.c b/object-refs.c
index a7d49c6..b1b8065 100644
--- a/object-refs.c
+++ b/object-refs.c
@@ -12,6 +12,18 @@ static unsigned int hash_obj(struct obje
 	return hash % n;
 }
 
+static void insert_ref_hash(struct object_refs *ref, struct object_refs **hash, unsigned int size)
+{
+	int j = hash_obj(ref->base, size);
+
+	while (hash[j]) {
+		j++;
+		if (j >= size)
+			j = 0;
+	}
+	hash[j] = ref;
+}
+
 static void grow_refs_hash(void)
 {
 	int i;
@@ -20,30 +32,16 @@ static void grow_refs_hash(void)
 
 	new_hash = calloc(new_hash_size, sizeof(struct object_refs *));
 	for (i = 0; i < refs_hash_size; i++) {
-		int j;
 		struct object_refs *ref = refs_hash[i];
 		if (!ref)
 			continue;
-		j = hash_obj(ref->base, new_hash_size);
-		new_hash[j] = ref;
+		insert_ref_hash(ref, new_hash, new_hash_size);
 	}
 	free(refs_hash);
 	refs_hash = new_hash;
 	refs_hash_size = new_hash_size;
 }
 
-static void insert_ref_hash(struct object_refs *ref)
-{
-	int j = hash_obj(ref->base, refs_hash_size);
-
-	while (refs_hash[j]) {
-		j++;
-		if (j >= refs_hash_size)
-			j = 0;
-	}
-	refs_hash[j] = ref;
-}
-
 static void add_object_refs(struct object *obj, struct object_refs *ref)
 {
 	int nr = nr_object_refs + 1;
@@ -51,7 +49,7 @@ static void add_object_refs(struct objec
 	if (nr > refs_hash_size * 2 / 3)
 		grow_refs_hash();
 	ref->base = obj;
-	insert_ref_hash(ref);
+	insert_ref_hash(ref, refs_hash, refs_hash_size);
 	nr_object_refs = nr;
 }
 
Previous: Andre NollNext: Junio C Hamano
Message 6 of 7 in “Odd behavior with git and cairo-devel repo”
  1. Art HaasJun 21, 2006
  2. Andre NollJun 21, 2006
  3. Junio C HamanoJun 21, 2006
  4. Art HaasJun 21, 2006
  5. Andre NollJun 21, 2006
  6. Linus TorvaldsJun 21, 2006
  7. Junio C HamanoJun 21, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.