git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] http: add_fill_function checks if function has been added
@ 2009-03-07 12:21 Tay Ray Chuan
  2009-03-07 20:18 ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Tay Ray Chuan @ 2009-03-07 12:21 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-03-09 12:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-07 12:21 [PATCH] http: add_fill_function checks if function has been added Tay Ray Chuan
2009-03-07 20:18 ` Junio C Hamano
2009-03-07 20:49   ` Tay Ray Chuan
2009-03-07 21:49     ` Junio C Hamano
2009-03-08 10:27       ` Tay Ray Chuan
2009-03-08 19:38         ` Junio C Hamano
2009-03-09 12:01           ` Tay Ray Chuan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).