aboutsummaryrefslogtreecommitdiffstats
path: root/src/helperfuncs.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2020-09-27 12:35:10 +0100
committerGravatar Sadie Powell2020-09-27 12:37:24 +0100
commitf6c4ff549809bb739c90ecd634a65f1185d94ae1 (patch)
tree68a643f268bd696c560625aea305a0cda3e77c7a /src/helperfuncs.cpp
parentRemove MODENOTICE from the oper command help too. (diff)
parentDocument the recent shun changes. (diff)
Merge branch 'insp3' into master.
Diffstat (limited to 'src/helperfuncs.cpp')
-rw-r--r--src/helperfuncs.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index cf07ef9e9..e4d928a4b 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -490,14 +490,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<char> 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.