chiark / gitweb /
Static buffers: Provide new rotating static buffer macros
[secnet.git] / util.c
diff --git a/util.c b/util.c
index 478d779cbf042b2de91738e2cd067840f573dde9..59ed427ca532956bdae93f31d0e898e4e1afd999 100644 (file)
--- a/util.c
+++ b/util.c
@@ -543,19 +543,13 @@ void string_item_to_iaddr(const item_t *item, uint16_t port, union iaddr *ia,
 #endif /* CONFIG_IPV6 */
 }
 
-#define IADDR_NBUFS_SHIFT 3
-#define IADDR_NBUFS (1 << IADDR_NBUFS_SHIFT)
+#define IADDR_NBUFS 8
 
 const char *iaddr_to_string(const union iaddr *ia)
 {
-    static int b;
-
-    b++;
-    b &= IADDR_NBUFS-1;
-
 #ifndef CONFIG_IPV6
 
-    static char bufs[IADDR_NBUFS][100];
+    SBUF_DEFINE(IADDR_NBUFS, 100);
 
     assert(ia->sa.sa_family == AF_INET);
 
@@ -565,7 +559,7 @@ const char *iaddr_to_string(const union iaddr *ia)
 
 #else /* CONFIG_IPV6 => we have adns_addr2text */
 
-    static char bufs[IADDR_NBUFS][1+ADNS_ADDR2TEXT_BUFLEN+20];
+    SBUF_DEFINE(IADDR_NBUFS, 1+ADNS_ADDR2TEXT_BUFLEN+20);
 
     int port;