summaryrefslogtreecommitdiff
blob: d05783c439a2ce577b73a3d21c2c5edf8b4b6d03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From 02c2595fdc259fa15b9a927779cbe65f381f4b26 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= <saghul@gmail.com>
Date: Fri, 23 May 2014 16:36:57 +0200
Subject: [PATCH] unix, windows: define UV__INET/6_ADDRSTRLEN constants

---
 src/inet.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/inet.c b/src/inet.c
index 9220de6..0eb9438 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -27,6 +27,9 @@
 #include "uv.h"
 #include "uv-common.h"
 
+#define UV__INET_ADDRSTRLEN         16
+#define UV__INET6_ADDRSTRLEN        46
+
 
 static int inet_ntop4(const unsigned char *src, char *dst, size_t size);
 static int inet_ntop6(const unsigned char *src, char *dst, size_t size);
@@ -49,7 +52,7 @@ int uv_inet_ntop(int af, const void* src, char* dst, size_t size) {
 
 static int inet_ntop4(const unsigned char *src, char *dst, size_t size) {
   static const char fmt[] = "%u.%u.%u.%u";
-  char tmp[sizeof "255.255.255.255"];
+  char tmp[UV__INET_ADDRSTRLEN];
   int l;
 
 #ifndef _WIN32
@@ -74,7 +77,7 @@ static int inet_ntop6(const unsigned char *src, char *dst, size_t size) {
    * Keep this in mind if you think this function should have been coded
    * to use pointer overlays.  All the world's not a VAX.
    */
-  char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
+  char tmp[UV__INET6_ADDRSTRLEN], *tp;
   struct { int base, len; } best, cur;
   unsigned int words[sizeof(struct in6_addr) / sizeof(uint16_t)];
   int i;
-- 
1.9.3