summaryrefslogtreecommitdiff
path: root/src/socket.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-03 01:52:59 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-03 01:52:59 +0000
commitde25d946733f774e3a5b53a58438a9c92af0acbe (patch)
tree459ccc3b0c2423f1592afec4b458615968a1176d /src/socket.cpp
parente57ed15735a3f23d6451845c7cf96758e6909d8c (diff)
Get rid of a bunch of memory-wasting C-style strings
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11796 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/socket.cpp')
-rw-r--r--src/socket.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/socket.cpp b/src/socket.cpp
index b719ebe82..00be4250b 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -72,13 +72,12 @@ bool InspIRCd::BindSocket(int sockfd, int port, const char* addr, bool dolisten)
}
// Open a TCP Socket
-int irc::sockets::OpenTCPSocket(const char* addr, int socktype)
+int irc::sockets::OpenTCPSocket(const std::string& addr, int socktype)
{
int sockfd;
int on = 1;
- addr = addr;
struct linger linger = { 0, 0 };
- if (!*addr)
+ if (addr.empty())
{
#ifdef IPV6
sockfd = socket (PF_INET6, socktype, 0);
@@ -86,7 +85,7 @@ int irc::sockets::OpenTCPSocket(const char* addr, int socktype)
#endif
sockfd = socket (PF_INET, socktype, 0);
}
- else if (strchr(addr,':'))
+ else if (addr.find(':') != std::string::npos)
sockfd = socket (PF_INET6, socktype, 0);
else
sockfd = socket (PF_INET, socktype, 0);
@@ -186,10 +185,10 @@ int InspIRCd::BindPorts(FailedPortList &failed_ports)
return bound;
}
-bool irc::sockets::aptosa(const char* addr, int port, irc::sockets::sockaddrs* sa)
+bool irc::sockets::aptosa(const std::string& addr, int port, irc::sockets::sockaddrs* sa)
{
memset(sa, 0, sizeof(*sa));
- if (!addr || !*addr)
+ if (addr.empty())
{
#ifdef IPV6
sa->in6.sin6_family = AF_INET6;
@@ -200,13 +199,13 @@ bool irc::sockets::aptosa(const char* addr, int port, irc::sockets::sockaddrs* s
#endif
return true;
}
- else if (inet_pton(AF_INET, addr, &sa->in4.sin_addr) > 0)
+ else if (inet_pton(AF_INET, addr.c_str(), &sa->in4.sin_addr) > 0)
{
sa->in4.sin_family = AF_INET;
sa->in4.sin_port = htons(port);
return true;
}
- else if (inet_pton(AF_INET6, addr, &sa->in6.sin6_addr) > 0)
+ else if (inet_pton(AF_INET6, addr.c_str(), &sa->in6.sin6_addr) > 0)
{
sa->in6.sin6_family = AF_INET6;
sa->in6.sin6_port = htons(port);