Skip to content

Commit fa165e9

Browse files
author
MarcoFalke
committed
Replace stoul with ToIntegral in dbwrapper
1 parent c0b6c96 commit fa165e9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/dbwrapper.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,15 @@ bool CDBWrapper::WriteBatch(CDBBatch& batch, bool fSync)
197197
return true;
198198
}
199199

200-
size_t CDBWrapper::DynamicMemoryUsage() const {
200+
size_t CDBWrapper::DynamicMemoryUsage() const
201+
{
201202
std::string memory;
202-
if (!pdb->GetProperty("leveldb.approximate-memory-usage", &memory)) {
203+
std::optional<size_t> parsed;
204+
if (!pdb->GetProperty("leveldb.approximate-memory-usage", &memory) || !(parsed = ToIntegral<size_t>(memory))) {
203205
LogPrint(BCLog::LEVELDB, "Failed to get approximate-memory-usage property\n");
204206
return 0;
205207
}
206-
return stoul(memory);
208+
return parsed.value();
207209
}
208210

209211
// Prefixed with null character to avoid collisions with other keys

test/lint/lint-locale-dependence.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export LC_ALL=C
4242
# TODO: Reduce KNOWN_VIOLATIONS by replacing uses of locale dependent snprintf with strprintf.
4343
KNOWN_VIOLATIONS=(
4444
"src/bitcoin-tx.cpp.*stoul"
45-
"src/dbwrapper.cpp.*stoul"
4645
"src/dbwrapper.cpp:.*vsnprintf"
4746
"src/rest.cpp:.*strtol"
4847
"src/test/dbwrapper_tests.cpp:.*snprintf"

0 commit comments

Comments
 (0)