MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / safe_strtou64

Function safe_strtou64

tensorflow/core/lib/strings/numbers.cc:264–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262}
263
264bool safe_strtou64(StringPiece str, uint64* value) {
265 SkipSpaces(&str);
266 if (!isdigit(SafeFirstChar(str))) return false;
267
268 uint64 result = 0;
269 do {
270 int digit = SafeFirstChar(str) - '0';
271 if ((kuint64max - digit) / 10 < result) {
272 return false;
273 }
274 result = result * 10 + digit;
275 str.remove_prefix(1);
276 } while (isdigit(SafeFirstChar(str)));
277
278 SkipSpaces(&str);
279 if (!str.empty()) return false;
280
281 *value = result;
282 return true;
283}
284
285bool safe_strto32(StringPiece str, int32* value) {
286 SkipSpaces(&str);

Callers 7

InitializeMethod · 0.85
InitMethod · 0.85
TESTFunction · 0.85
ProtoParseNumericFunction · 0.85
ParseConfigMethod · 0.85
requestDiskByteUsageMethod · 0.85
GetEnvVarFunction · 0.85

Calls 3

SkipSpacesFunction · 0.85
SafeFirstCharFunction · 0.85
emptyMethod · 0.45

Tested by 1

TESTFunction · 0.68