From: Tay Ray Chuan <rctay89@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH] http: add_fill_function checks if function has been added
Date: Sat, 07 Mar 2009 20:21:04 +0800 [thread overview]
Message-ID: <49B266B0.4020304@gmail.com> (raw)
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 reply other threads:[~2009-03-07 12:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-07 12:21 Tay Ray Chuan [this message]
2009-03-07 20:18 ` [PATCH] http: add_fill_function checks if function has been added 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49B266B0.4020304@gmail.com \
--to=rctay89@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).