[PATCH 12/31] ipv6: More buffers in iaddr_to_string
Ian Jackson
ijackson at chiark.greenend.org.uk
Sat Sep 20 01:32:07 BST 2014
We are going to have addresses of multiple address families in various
places, which will mean more calls to iaddr_to_string for the benefit
of the same logging statement.
Increase the number of static buffers used by iaddr_to_string from 2
to 8.
Signed-off-by: Ian Jackson <ijackson at chiark.greenend.org.uk>
---
util.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/util.c b/util.c
index 3e0f5ce..5c6678d 100644
--- a/util.c
+++ b/util.c
@@ -463,12 +463,16 @@ extern void slilog_part(struct log_if *lf, int priority, const char *message, ..
va_end(ap);
}
+#define IADDR_NBUFS_SHIFT 3
+#define IADDR_NBUFS (1 << IADDR_NBUFS_SHIFT)
+
const char *iaddr_to_string(const union iaddr *ia)
{
- static char bufs[2][100];
+ static char bufs[IADDR_NBUFS][100];
static int b;
- b ^= 1;
+ b++;
+ b &= IADDR_NBUFS-1;
assert(ia->sa.sa_family == AF_INET);
--
1.7.10.4
More information about the sgo-software-discuss
mailing list