aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authordaniel <arowser@gmail.com>2014-05-27 11:44:55 +0800
committerWladimir J. van der Laan <laanwj@gmail.com>2014-06-23 11:59:58 +0200
commitfcb0a1bb9cea0e627152e544b0701c039cc3f60e (patch)
tree94f006ec2ba2e16f4137ff4e4203340e50a1c3a6 /src/util.cpp
parent5459116d610268da79a8973f66a5873ddb6732fb (diff)
change "char pch[200000]" to "new char[200000]"
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 30590912ff..1480b2ebf8 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -168,15 +168,14 @@ void RandAddSeedPerfmon()
#ifdef WIN32
// Don't need this on Linux, OpenSSL automatically uses /dev/urandom
// Seed with the entire set of perfmon data
- unsigned char pdata[250000];
- memset(pdata, 0, sizeof(pdata));
- unsigned long nSize = sizeof(pdata);
- long ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, pdata, &nSize);
+ std::vector <unsigned char> vData(250000,0);
+ unsigned long nSize = vData.size();
+ long ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, begin_ptr(vData), &nSize);
RegCloseKey(HKEY_PERFORMANCE_DATA);
if (ret == ERROR_SUCCESS)
{
- RAND_add(pdata, nSize, nSize/100.0);
- OPENSSL_cleanse(pdata, nSize);
+ RAND_add(begin_ptr(vData), nSize, nSize/100.0);
+ OPENSSL_cleanse(begin_ptr(vData), nSize);
LogPrint("rand", "RandAddSeed() %lu bytes\n", nSize);
}
#endif
@@ -1141,15 +1140,15 @@ void ShrinkDebugFile()
if (file && boost::filesystem::file_size(pathLog) > 10 * 1000000)
{
// Restart the file with some of the end
- char pch[200000];
- fseek(file, -sizeof(pch), SEEK_END);
- int nBytes = fread(pch, 1, sizeof(pch), file);
+ std::vector <char> vch(200000,0);
+ fseek(file, -vch.size(), SEEK_END);
+ int nBytes = fread(begin_ptr(vch), 1, vch.size(), file);
fclose(file);
file = fopen(pathLog.string().c_str(), "w");
if (file)
{
- fwrite(pch, 1, nBytes, file);
+ fwrite(begin_ptr(vch), 1, nBytes, file);
fclose(file);
}
}