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 <redacted>
---
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