X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fhelperfuncs.cpp;h=795f858fa35018171d424ebb70a9051866936355;hb=b4a174ee9c32d62ea6bf010e837e8c5b1c3d36a3;hp=e019a660bc7871e1d08189251d7169ed30085f89;hpb=ccebfe6e637b420bef05e8e0faf29bb19f1883d9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index e019a660b..795f858fa 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -1,18 +1,18 @@ /* * InspIRCd -- Internet Relay Chat Daemon * - * Copyright (C) 2019 Matt Schatz + * Copyright (C) 2019-2020 Matt Schatz * Copyright (C) 2018 linuxdaemon * Copyright (C) 2013 Daniel Vassdal * Copyright (C) 2013 Adam * Copyright (C) 2012-2015 Attila Molnar - * Copyright (C) 2012-2014, 2017-2018 Sadie Powell + * Copyright (C) 2012-2014, 2017-2018, 2020 Sadie Powell * Copyright (C) 2012, 2018 Robby * Copyright (C) 2012 ChrisTX * Copyright (C) 2009-2010 Daniel De Graaf - * Copyright (C) 2007, 2010 Craig Edwards * Copyright (C) 2007 Dennis Friis * Copyright (C) 2006-2008 Robin Burchell + * Copyright (C) 2005, 2007, 2010 Craig Edwards * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -35,8 +35,6 @@ #include "inspircd.h" #include "xline.h" -#include "exitcodes.h" -#include /* Find a user record by nickname and return a pointer to it */ User* InspIRCd::FindNick(const std::string &nick) @@ -340,7 +338,7 @@ bool InspIRCd::IsSID(const std::string &str) */ return ((str.length() == 3) && isdigit(str[0]) && ((str[1] >= 'A' && str[1] <= 'Z') || isdigit(str[1])) && - ((str[2] >= 'A' && str[2] <= 'Z') || isdigit(str[2]))); + ((str[2] >= 'A' && str[2] <= 'Z') || isdigit(str[2]))); } /** A lookup table of values for multiplier characters used by @@ -383,7 +381,7 @@ bool InspIRCd::Duration(const std::string& str, unsigned long& duration) } else { - /* Found something thats not a number, find out how much + /* Found something that's not a number, find out how much * it multiplies the built up number by, multiply the total * and reset the built up number. */ @@ -517,14 +515,12 @@ std::string InspIRCd::TimeString(time_t curtime, const char* format, bool utc) std::string InspIRCd::GenRandomStr(unsigned int length, bool printable) { - char* buf = new char[length]; - GenRandom(buf, length); - std::string rv; - rv.resize(length); - for(size_t i = 0; i < length; i++) - rv[i] = printable ? 0x3F + (buf[i] & 0x3F) : buf[i]; - delete[] buf; - return rv; + std::vector str(length); + GenRandom(&str[0], length); + if (printable) + for (size_t i = 0; i < length; i++) + str[i] = 0x3F + (str[i] & 0x3F); + return std::string(&str[0], str.size()); } // NOTE: this has a slight bias for lower values if max is not a power of 2.