--- iputils/ping.c.addrcache	2002-09-20 17:08:11.000000000 +0200
+++ iputils/ping.c	2003-05-15 16:41:19.000000000 +0200
@@ -1124,6 +1124,12 @@
 {
 	struct hostent *hp;
 	static char buf[4096];
+	static __u32 addr_cache = 0;
+
+	if ( addr == addr_cache )
+		return buf;
+
+	addr_cache = addr;
 
 	if ((options & F_NUMERIC) ||
 	    !(hp = gethostbyaddr((char *)&addr, 4, AF_INET)))
--- iputils/ping6.c.addrcache	2002-09-20 17:08:11.000000000 +0200
+++ iputils/ping6.c	2003-05-15 16:41:19.000000000 +0200
@@ -893,7 +893,12 @@
  */
 char * pr_addr(struct in6_addr *addr)
 {
-	struct hostent *hp = NULL;
+	static struct hostent *hp;
+	static struct in6_addr addr_cache;
+
+	if (memcmp(addr, &addr_cache, sizeof(addr_cache)) == 0)
+		return hp ? hp->h_name : pr_addr_n(addr);
+	memcpy(&addr_cache, addr, sizeof(addr_cache));
 
 	if (!(options&F_NUMERIC))
 		hp = gethostbyaddr((__u8*)addr, sizeof(struct in6_addr), AF_INET6);
