summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-04-11 21:35:17 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-04-11 21:35:17 +0000
commite8da3ac2c037f645b0f29f12304e8b4c6c2988e0 (patch)
tree13fd8c422dd3c05840d9927ff71b3dfbee108ae3 /src
parent24c169c39fb8b2efb0138cbd9220ae75ecb839bd (diff)
Dns free() errors fixed
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1055 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/dns.cpp9
-rw-r--r--src/dnsqueue.cpp19
2 files changed, 11 insertions, 17 deletions
diff --git a/src/dns.cpp b/src/dns.cpp
index 30d05e2a3..13a80311a 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -188,11 +188,7 @@ void DNS::dns_init_2(const char* dnsserver) { /* populates servers4 struct with
int i;
in_addr addr4;
char buf[1024];
- if (initdone == 1)
- return;
i4 = 0;
-
- initdone = 1;
srand((unsigned int) TIME);
memset(servers4,'\0',sizeof(in_addr) * DNS_MAX);
if (dns_aton4_s(dnsserver,&addr4) != NULL)
@@ -686,6 +682,11 @@ DNS::DNS(std::string dnsserver)
dns_init_2(dnsserver.c_str());
}
+void DNS::SetNS(std::string dnsserver)
+{
+ dns_init_2(dnsserver.c_str());
+}
+
DNS::~DNS()
{
}
diff --git a/src/dnsqueue.cpp b/src/dnsqueue.cpp
index e2230b584..e949ddab9 100644
--- a/src/dnsqueue.cpp
+++ b/src/dnsqueue.cpp
@@ -168,28 +168,21 @@ extern time_t TIME;
class Lookup {
private:
- DNS* resolver;
+ DNS resolver;
char u[NICKMAX];
public:
Lookup()
{
strcpy(u,"");
- resolver = NULL;
}
void Reset()
{
strcpy(u,"");
- if (resolver)
- delete resolver;
- resolver = NULL;
}
~Lookup()
{
- if (resolver)
- delete resolver;
- resolver = NULL;
}
bool DoLookup(std::string nick)
@@ -198,8 +191,8 @@ public:
if (usr)
{
log(DEBUG,"New Lookup class for %s with DNSServer set to '%s'",nick.c_str(),DNSServer);
- resolver = new DNS(std::string(DNSServer));
- if (!resolver->ReverseLookup(std::string(usr->host)))
+ resolver.SetNS(std::string(DNSServer));
+ if (!resolver.ReverseLookup(std::string(usr->host)))
return false;
strlcpy(u,nick.c_str(),NICKMAX);
return true;
@@ -210,11 +203,11 @@ public:
bool Done()
{
userrec* usr = NULL;
- if (resolver->HasResult())
+ if (resolver.HasResult())
{
- if (resolver->GetFD() != 0)
+ if (resolver.GetFD() != 0)
{
- std::string hostname = resolver->GetResult();
+ std::string hostname = resolver.GetResult();
usr = Find(u);
if (usr)
{