diff options
-rw-r--r-- | include/hashcomp.h | 22 | ||||
-rw-r--r-- | include/socketengine.h | 8 | ||||
-rw-r--r-- | include/users.h | 4 | ||||
-rw-r--r-- | src/hashcomp.cpp | 2 | ||||
-rw-r--r-- | src/language.cpp | 12 | ||||
-rw-r--r-- | src/misc.cpp | 1 | ||||
-rw-r--r-- | src/sockets.cpp | 18 |
7 files changed, 40 insertions, 27 deletions
diff --git a/include/hashcomp.h b/include/hashcomp.h index abf29a400..77e3c0439 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -45,15 +45,9 @@ namespace Anope # define unordered_map hash_map # endif #else -# if _MSV_VER >= 1600 /* MSVC 2010+ has tr1. Though MSVC and GCC use different includes! */ -# include <unordered_map> -# define unordered_map_namespace std::tr1 -# else -# include <hash_map> -# define unordered_map_namespace stdext -# define unordered_map hash_map -# endif +# include <unordered_map> +# define unordered_map_namespace std::tr1 #endif /******************************************************* @@ -247,8 +241,9 @@ namespace std /** An overload for std::equal_to<ci::string> that uses Anope::string, passed for the fourth temmplate * argument for unordered_map */ - template<> struct equal_to<ci::string> + template<> class CoreExport equal_to<ci::string> { + public: /** Compare two Anope::strings as ci::strings * @paarm s1 The first string * @param s2 The second string @@ -260,8 +255,9 @@ namespace std /** An overload for std::equal_to<irc::string> that uses Anope::string, passed for the fourth template * argument for unorderd_map */ - template<> struct equal_to<irc::string> + template<> class CoreExport equal_to<irc::string> { + public: /** Compare two Anope::strings as irc::strings * @param s1 The first string * @param s2 The second string @@ -273,8 +269,9 @@ namespace std /** An overload for std::less<ci::string> that uses Anope::string, passed for the third template argument * to std::map and std::multimap */ - template<> struct less<ci::string> + template<> class CoreExport less<ci::string> { + public: /** Compare two Anope::strings as ci::strings and find which one is less * @param s1 The first string * @param s2 The second string @@ -286,8 +283,9 @@ namespace std /** An overload for std;:less<irc::string> that uses Anope::string, passed for the third tempalte argument * to std::map and std::multimap */ - template<> struct less<irc::string> + template<> class CoreExport less<irc::string> { + public: /** Compare two Anope::strings as irc::strings and find which one is less * @param s1 The first string * @param s2 The second string diff --git a/include/socketengine.h b/include/socketengine.h index 042d4b410..7279ba3ad 100644 --- a/include/socketengine.h +++ b/include/socketengine.h @@ -15,16 +15,20 @@ class CoreExport SocketEngineBase { public: +#ifdef _WIN32 + /* Windows crap */ + WSADATA wsa; +#endif /* Map of sockets */ std::map<int, Socket *> Sockets; /** Default constructor */ - SocketEngineBase() { } + SocketEngineBase(); /** Default destructor */ - virtual ~SocketEngineBase() { } + virtual ~SocketEngineBase(); /** Add a socket to the internal list * @param s The socket diff --git a/include/users.h b/include/users.h index f545c15a1..2c10690c4 100644 --- a/include/users.h +++ b/include/users.h @@ -11,8 +11,8 @@ /* Hash maps used for users. Note UserListByUID will not be used on non-TS6 IRCds, and should never * be assumed to have users */ -typedef unordered_map_namespace::unordered_map<Anope::string, User *, ci::hash, std::less<ci::string> > user_map; -typedef unordered_map_namespace::unordered_map<Anope::string, User *, ci::hash, std::less<ci::string> > user_uid_map; +typedef unordered_map_namespace::unordered_map<Anope::string, User *, ci::hash, std::equal_to<ci::string> > user_map; +typedef unordered_map_namespace::unordered_map<Anope::string, User *, Anope::hash> user_uid_map; extern CoreExport user_map UserListByNick; extern CoreExport user_uid_map UserListByUID; diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 839d65da8..129f38e07 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -197,7 +197,7 @@ bool std::less<ci::string>::operator()(const Anope::string &s1, const Anope::str */ bool std::less<irc::string>::operator()(const Anope::string &s1, const Anope::string &s2) const { - return s2.irc_str().compare(s2.irc_str()) < 0; + return s1.irc_str().compare(s2.irc_str()) < 0; } sepstream::sepstream(const Anope::string &source, char seperator) : tokens(source), sep(seperator) diff --git a/src/language.cpp b/src/language.cpp index 318f10f38..6e9192756 100644 --- a/src/language.cpp +++ b/src/language.cpp @@ -84,7 +84,7 @@ static void load_lang(int index, const char *filename) } else if (num != NUM_STRINGS) Alog() << "Warning: Bad number of strings (" << num << " , wanted " << NUM_STRINGS << ") for language " << index << " (" << filename << ")"; - langtexts[index] = new char *[NUM_STRINGS]; + langtexts[index] = static_cast<char **>(scalloc(sizeof(char *), NUM_STRINGS)); if (num > NUM_STRINGS) num = NUM_STRINGS; for (i = 0; i < num; ++i) @@ -99,7 +99,7 @@ static void load_lang(int index, const char *filename) if (langtexts[index][i]) free(langtexts[index][i]); // XXX } - delete [] langtexts[index]; + free(langtexts[index]); langtexts[index] = NULL; return; } @@ -113,7 +113,7 @@ static void load_lang(int index, const char *filename) if (langtexts[index][i]) free(langtexts[index][i]); // XXX } - delete [] langtexts[index]; + free(langtexts[index]); langtexts[index] = NULL; return; } @@ -125,13 +125,13 @@ static void load_lang(int index, const char *filename) if (langtexts[index][i]) free(langtexts[index][i]); // XXX } - delete [] langtexts[index]; + free(langtexts[index]); langtexts[index] = NULL; return; } else { - langtexts[index][i] = new char[len + 1]; + langtexts[index][i] = static_cast<char *>(malloc(len + 1)); fseek(f, pos, SEEK_SET); if (fread(langtexts[index][i], 1, len, f) != len) { @@ -141,7 +141,7 @@ static void load_lang(int index, const char *filename) if (langtexts[index][i]) free(langtexts[index][i]); } - delete [] langtexts[index]; + free(langtexts[index]); langtexts[index] = NULL; return; } diff --git a/src/misc.cpp b/src/misc.cpp index 0e838695d..f44532220 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -12,7 +12,6 @@ #include "services.h" #include "language.h" -#include "hashcomp.h" // If this gets added to services.h or someplace else later, remove it from here -- CyberBotX /* Cheaper than isspace() or isblank() */ #define issp(c) ((c) == 32) diff --git a/src/sockets.cpp b/src/sockets.cpp index 345bb7032..b85255523 100644 --- a/src/sockets.cpp +++ b/src/sockets.cpp @@ -15,6 +15,21 @@ static void TrimBuf(std::string &buffer) buffer.erase(buffer.length() - 1); } +SocketEngineBase::SocketEngineBase() +{ +#ifdef _WIN32 + if (WSAStartup(MAKEWORD(2, 0), &wsa)) + Alog() << "Failed to initialize WinSock library"; +#endif +} + +SocketEngineBase::~SocketEngineBase() +{ +#ifdef _WIN32 + WSACleanup(); +#endif +} + /** Constructor * @param nsock The socket * @param nIPv6 IPv6? @@ -232,9 +247,6 @@ void Socket::Write(const Anope::string &message) */ ClientSocket::ClientSocket(const Anope::string &nTargetHost, int nPort, const Anope::string &nBindHost, bool nIPv6) : Socket(0, nIPv6), TargetHost(nTargetHost), Port(nPort), BindHost(nBindHost) { - if (!IPv6 && (TargetHost.find(':') != Anope::string::npos || BindHost.find(':') != Anope::string::npos)) - IPv6 = true; - addrinfo hints; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = 0; |