chiark / gitweb /
ipv6: More buffers in iaddr_to_string
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 29 Jun 2014 22:15:58 +0000 (23:15 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 5 Oct 2014 20:27:28 +0000 (21:27 +0100)
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@chiark.greenend.org.uk>
util.c

diff --git a/util.c b/util.c
index 207abb2b7163efa62e9e7c6adbbd9a9645384988..5658aa3ca62c0efe9dce7b048bb08dade1e5906d 100644 (file)
--- a/util.c
+++ b/util.c
@@ -477,12 +477,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);