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

[PATCH] http: add_fill_function checks if function has been added

From
Tay Ray Chuan <rctay89@gmail.com>
Date
Mar 7, 2009, 12:21 UTC
Message-ID
<49B266B0.4020304@gmail.com>

This patch ensures that the same fill function is called once so to prevent any possible issues.

Nevertheless, calling a fill function repeatedly in ''fill_active_slots'' will not lead to any obvious change in existing behavior, though performance might be affected.

''add_fill_action'' checks if the function to be added has already been added. Allocation of memory for the list ''fill_chain*'' is postponed until the check passes, unlike previously.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
 http.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/http.c b/http.c
index ee58799..cdedeb6 100644
--- a/http.c
+++ b/http.c
@@ -408,13 +408,17 @@ static struct fill_chain *fill_cfg = NULL;

 void add_fill_function(void *data, int (*fill)(void *))
 {
-	struct fill_chain *new = xmalloc(sizeof(*new));
+	struct fill_chain *new;
 	struct fill_chain **linkp = &fill_cfg;
+	for (;*linkp; linkp = &(*linkp)->next)
+		if ((*linkp)->fill == fill)
+			return;
+
+	new = xmalloc(sizeof(*new));
 	new->data = data;
 	new->fill = fill;
 	new->next = NULL;
-	while (*linkp)
-		linkp = &(*linkp)->next;
+
 	*linkp = new;
 }
-- 
1.6.2.rc1
Next: Junio C Hamano
Message 1 of 7 in “http: add_fill_function checks if function has been added”
  1. http: add_fill_function checks if function has been addedTay Ray Chuan, Mar 7, 2009
  2. Junio C HamanoMar 7, 2009
  3. Tay Ray ChuanMar 7, 2009
  4. Junio C HamanoMar 7, 2009
  5. Tay Ray ChuanMar 8, 2009
  6. Junio C HamanoMar 8, 2009
  7. Tay Ray ChuanMar 9, 2009

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.