nsAllocator::Free(netAddr); if(PR_SUCCESS == status) return rv;
nsDNSLookup::InitiateLookup(void){    nsresult rv = NS_OK;//    nsAutoCMonitor mon(this);	// XXX don't think we need this	    PRStatus status = PR_SUCCESS;    PRBool numeric = PR_TRUE;    for (const char *hostCheck = mHostName; *hostCheck; hostCheck++) {        if (!nsString2::IsDigit(*hostCheck) && (*hostCheck != '.') ) {            numeric = PR_FALSE;            break;        }    }    if (numeric) {        // If it is numeric then try to convert it into an IP-Address        PRNetAddr *netAddr = (PRNetAddr*)nsAllocator::Alloc(sizeof(PRNetAddr));        if (!netAddr) return NS_ERROR_OUT_OF_MEMORY;        status = PR_StringToNetAddr(mHostName, netAddr);        if (PR_SUCCESS == status) {            // slam the IP in and move on.            mHostEntry.bufLen = PR_NETDB_BUF_SIZE;            PRUint32 hostNameLen = nsCRT::strlen(mHostName);            mHostEntry.hostEnt.h_name = (char*)BufAlloc(hostNameLen + 1,                                                        (char**)&mHostEntry.bufPtr,                                                        &mHostEntry.bufLen,                                                        0);            memcpy(mHostEntry.hostEnt.h_name, mHostName, hostNameLen + 1);            mHostEntry.hostEnt.h_aliases = (char**)BufAlloc(1 * sizeof(char*),                                                            (char**)&mHostEntry.bufPtr,                                                            &mHostEntry.bufLen,                                                            sizeof(char **));            mHostEntry.hostEnt.h_aliases[0] = '\0';            mHostEntry.hostEnt.h_addrtype = 2;            mHostEntry.hostEnt.h_length = 4;            mHostEntry.hostEnt.h_addr_list = (char**)BufAlloc(2 * sizeof(char*),                                                              (char**)&mHostEntry.bufPtr,                                                              &mHostEntry.bufLen,                                                              sizeof(char **));            mHostEntry.hostEnt.h_addr_list[0] = (char*)BufAlloc(mHostEntry.hostEnt.h_length,                                                                (char**)&mHostEntry.bufPtr,                                                                &mHostEntry.bufLen,                                                                0);            memcpy(mHostEntry.hostEnt.h_addr_list[0], &netAddr->inet.ip, mHostEntry.hostEnt.h_length);            mHostEntry.hostEnt.h_addr_list[1] = '\0';            return CompletedLookup(NS_OK);        }    }    // Incomming hostname is not a numeric ip address. Need to do the actual    // dns lookup.#if defined(XP_MAC)    OSErr   err;	    err = OTInetStringToAddress(nsDNSService::gService->mServiceRef, (char *)mHostName, (InetHostInfo *)&mInetHostInfo);    if (err != noErr)        rv = NS_ERROR_UNEXPECTED;#endif /* XP_MAC */#if defined(XP_PC) && !defined(XP_OS2)    mMsgID = nsDNSService::gService->AllocMsgID();    if (mMsgID == 0)        return NS_ERROR_UNEXPECTED;    {        nsAutoMonitor mon(nsDNSService::gService->mMonitor);    // protect against lookup completing before WSAAsyncGetHostByName returns, better to refcount lookup        mLookupHandle = WSAAsyncGetHostByName(nsDNSService::gService->mDNSWindow, mMsgID,                                          mHostName, (char *)&mHostEntry.hostEnt, PR_NETDB_BUF_SIZE);        // check for error conditions        if (mLookupHandle == nsnull) {            rv = NS_ERROR_UNEXPECTED;  // or call WSAGetLastError() for details;		    // While we would like to use mLookupHandle to allow for canceling the request in		    // the future, there is a bug with winsock2 on win95 that causes WSAAsyncGetHostByName		    // to always return the same value.  We have worked around this problem by using the		    // msgID to identify which lookup has completed, rather than the handle, however, we		    // still need to identify when this is a problem (by comparing the return values of		    // the first two calls made to WSAAsyncGetHostByName), to avoid using the handle on		    // those systems.  For more info, see bug 23709.        }    }#endif /* XP_PC */#ifdef XP_UNIX    // temporary SYNC version    status = PR_GetHostByName(mHostName, mHostEntry.buffer, PR_NETDB_BUF_SIZE, &(mHostEntry.hostEnt));    if (PR_SUCCESS != status) rv = NS_ERROR_UNKNOWN_HOST;    return CompletedLookup(rv);#endif /* XP_UNIX */    return rv;}