@@ -1459,91 +1459,3 @@ PHPAPI int php_poll2(php_pollfd *ufds, unsigned int nfds, int timeout)
14591459 return n ;
14601460}
14611461#endif
1462-
1463- #if defined(HAVE_GETHOSTBYNAME_R )
1464- #ifdef HAVE_FUNC_GETHOSTBYNAME_R_6
1465- static struct hostent * gethostname_re (const char * host ,struct hostent * hostbuf ,char * * tmphstbuf ,size_t * hstbuflen )
1466- {
1467- struct hostent * hp ;
1468- int herr ,res ;
1469-
1470- if (* hstbuflen == 0 ) {
1471- * hstbuflen = 1024 ;
1472- * tmphstbuf = (char * )malloc (* hstbuflen );
1473- }
1474-
1475- while (( res =
1476- gethostbyname_r (host ,hostbuf ,* tmphstbuf ,* hstbuflen ,& hp ,& herr ))
1477- && (errno == ERANGE )) {
1478- /* Enlarge the buffer. */
1479- * hstbuflen *= 2 ;
1480- * tmphstbuf = (char * )realloc (* tmphstbuf ,* hstbuflen );
1481- }
1482-
1483- if (res != 0 ) {
1484- return NULL ;
1485- }
1486-
1487- return hp ;
1488- }
1489- #endif
1490- #ifdef HAVE_FUNC_GETHOSTBYNAME_R_5
1491- static struct hostent * gethostname_re (const char * host ,struct hostent * hostbuf ,char * * tmphstbuf ,size_t * hstbuflen )
1492- {
1493- struct hostent * hp ;
1494- int herr ;
1495-
1496- if (* hstbuflen == 0 ) {
1497- * hstbuflen = 1024 ;
1498- * tmphstbuf = (char * )malloc (* hstbuflen );
1499- }
1500-
1501- while ((NULL == ( hp =
1502- gethostbyname_r (host ,hostbuf ,* tmphstbuf ,* hstbuflen ,& herr )))
1503- && (errno == ERANGE )) {
1504- /* Enlarge the buffer. */
1505- * hstbuflen *= 2 ;
1506- * tmphstbuf = (char * )realloc (* tmphstbuf ,* hstbuflen );
1507- }
1508- return hp ;
1509- }
1510- #endif
1511- #ifdef HAVE_FUNC_GETHOSTBYNAME_R_3
1512- static struct hostent * gethostname_re (const char * host ,struct hostent * hostbuf ,char * * tmphstbuf ,size_t * hstbuflen )
1513- {
1514- if (* hstbuflen == 0 ) {
1515- * hstbuflen = sizeof (struct hostent_data );
1516- * tmphstbuf = (char * )malloc (* hstbuflen );
1517- } else {
1518- if (* hstbuflen < sizeof (struct hostent_data )) {
1519- * hstbuflen = sizeof (struct hostent_data );
1520- * tmphstbuf = (char * )realloc (* tmphstbuf , * hstbuflen );
1521- }
1522- }
1523- memset ((void * )(* tmphstbuf ),0 ,* hstbuflen );
1524-
1525- if (0 != gethostbyname_r (host ,hostbuf ,(struct hostent_data * )* tmphstbuf )) {
1526- return NULL ;
1527- }
1528-
1529- return hostbuf ;
1530- }
1531- #endif
1532- #endif
1533-
1534- PHPAPI struct hostent * php_network_gethostbyname (const char * name ) {
1535- #if !defined(HAVE_GETHOSTBYNAME_R )
1536- return gethostbyname (name );
1537- #else
1538- if (FG (tmp_host_buf )) {
1539- free (FG (tmp_host_buf ));
1540- }
1541-
1542- FG (tmp_host_buf ) = NULL ;
1543- FG (tmp_host_buf_len ) = 0 ;
1544-
1545- memset (& FG (tmp_host_info ), 0 , sizeof (struct hostent ));
1546-
1547- return gethostname_re (name , & FG (tmp_host_info ), & FG (tmp_host_buf ), & FG (tmp_host_buf_len ));
1548- #endif
1549- }
0 commit comments