MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / ParseInt32

Function ParseInt32

src/utilstrencodings.cpp:430–444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

428}
429
430bool ParseInt32(const std::string& str, int32_t *out)
431{
432 if (!ParsePrechecks(str))
433 return false;
434 char *endp = NULL;
435 errno = 0; // strtol will not set errno if valid
436 long int n = strtol(str.c_str(), &endp, 10);
437 if(out) *out = (int32_t)n;
438 // Note that strtol returns a *long int*, so even if strtol doesn't report a over/underflow
439 // we still have to check that the returned value is within the range of an *int32_t*. On 64-bit
440 // platforms the size of these types may be different.
441 return endp && *endp == 0 && !errno &&
442 n >= std::numeric_limits<int32_t>::min() &&
443 n <= std::numeric_limits<int32_t>::max();
444}
445
446bool ParseInt64(const std::string& str, int64_t *out)
447{

Callers 5

rest_getutxosFunction · 0.85
SplitHostPortFunction · 0.85
CSubNetMethod · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
get_intMethod · 0.85

Calls 1

ParsePrechecksFunction · 0.85

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68