Skip to content

Commit fcb0a1b

Browse files
arowserlaanwj
authored andcommitted
change "char pch[200000]" to "new char[200000]"
1 parent 5459116 commit fcb0a1b

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/util.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,14 @@ void RandAddSeedPerfmon()
168168
#ifdef WIN32
169169
// Don't need this on Linux, OpenSSL automatically uses /dev/urandom
170170
// Seed with the entire set of perfmon data
171-
unsigned char pdata[250000];
172-
memset(pdata, 0, sizeof(pdata));
173-
unsigned long nSize = sizeof(pdata);
174-
long ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, pdata, &nSize);
171+
std::vector <unsigned char> vData(250000,0);
172+
unsigned long nSize = vData.size();
173+
long ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, begin_ptr(vData), &nSize);
175174
RegCloseKey(HKEY_PERFORMANCE_DATA);
176175
if (ret == ERROR_SUCCESS)
177176
{
178-
RAND_add(pdata, nSize, nSize/100.0);
179-
OPENSSL_cleanse(pdata, nSize);
177+
RAND_add(begin_ptr(vData), nSize, nSize/100.0);
178+
OPENSSL_cleanse(begin_ptr(vData), nSize);
180179
LogPrint("rand", "RandAddSeed() %lu bytes\n", nSize);
181180
}
182181
#endif
@@ -1141,15 +1140,15 @@ void ShrinkDebugFile()
11411140
if (file && boost::filesystem::file_size(pathLog) > 10 * 1000000)
11421141
{
11431142
// Restart the file with some of the end
1144-
char pch[200000];
1145-
fseek(file, -sizeof(pch), SEEK_END);
1146-
int nBytes = fread(pch, 1, sizeof(pch), file);
1143+
std::vector <char> vch(200000,0);
1144+
fseek(file, -vch.size(), SEEK_END);
1145+
int nBytes = fread(begin_ptr(vch), 1, vch.size(), file);
11471146
fclose(file);
11481147

11491148
file = fopen(pathLog.string().c_str(), "w");
11501149
if (file)
11511150
{
1152-
fwrite(pch, 1, nBytes, file);
1151+
fwrite(begin_ptr(vch), 1, nBytes, file);
11531152
fclose(file);
11541153
}
11551154
}

0 commit comments

Comments
 (0)