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

Function ParseInt32

src/utilstrencodings.cpp:276–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274}
275
276bool ParseInt32(const std::string& str, int32_t *out)
277{
278 if (!ParsePrechecks(str))
279 return false;
280 char *endp = nullptr;
281 errno = 0; // strtol will not set errno if valid
282 long int n = strtol(str.c_str(), &endp, 10);
283 if(out) *out = (int32_t)n;
284 // Note that strtol returns a *long int*, so even if strtol doesn't report an over/underflow
285 // we still have to check that the returned value is within the range of an *int32_t*. On 64-bit
286 // platforms the size of these types may be different.
287 return endp && *endp == 0 && !errno &&
288 n >= std::numeric_limits<int32_t>::min() &&
289 n <= std::numeric_limits<int32_t>::max();
290}
291
292bool ParseInt64(const std::string& str, int64_t *out)
293{

Callers 3

rest_getutxosFunction · 0.70
SplitHostPortFunction · 0.70
LookupSubNetFunction · 0.70

Calls 2

maxFunction · 0.85
ParsePrechecksFunction · 0.70

Tested by

no test coverage detected