Ignore:
Timestamp:
Dec 2, 2007 3:36:46 PM (16 years ago)
Author:
bennylp
Message:

More ticket #415: Added pj_sockaddr_get_len() and pj_inet_ntop2(), and fixed Symbian combilation warnings with gcce

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/addr_resolv_sock.c

    r1601 r1608  
    6262#if defined(PJ_SOCK_HAS_GETADDRINFO) && PJ_SOCK_HAS_GETADDRINFO!=0 
    6363    char nodecopy[PJ_MAX_HOSTNAME]; 
    64     struct addrinfo hint, *res; 
     64    struct addrinfo hint, *res, *orig_res; 
    6565    unsigned i; 
    6666    int rc; 
     
    8585        return PJ_ERESOLVE; 
    8686 
     87    orig_res = res; 
     88 
    8789    /* Enumerate each item in the result */ 
    8890    for (i=0; i<*count && res; res=res->ai_next) { 
    89         int len; 
    90  
    9191        /* Ignore unwanted address families */ 
    9292        if (af!=PJ_AF_UNSPEC && res->ai_family != af) 
     
    9494 
    9595        /* Store canonical name (possibly truncating the name) */ 
    96         pj_ansi_strncpy(ai[i].ai_canonname, res->ai_canonname, 
    97                         sizeof(ai[i].ai_canonname)); 
    98         ai[i].ai_canonname[sizeof(ai[i].ai_canonname)-1] = '\0'; 
     96        if (res->ai_canonname) { 
     97            pj_ansi_strncpy(ai[i].ai_canonname, res->ai_canonname, 
     98                            sizeof(ai[i].ai_canonname)); 
     99            ai[i].ai_canonname[sizeof(ai[i].ai_canonname)-1] = '\0'; 
     100        } else { 
     101            pj_ansi_strcpy(ai[i].ai_canonname, nodecopy); 
     102        } 
    99103 
    100104        /* Store address */ 
     
    107111 
    108112    *count = i; 
     113 
     114    freeaddrinfo(orig_res); 
    109115 
    110116    /* Done */ 
Note: See TracChangeset for help on using the changeset viewer.