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

Function safe_strtou32

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

Source from the content-addressed store, hash-verified

313}
314
315bool safe_strtou32(StringPiece str, uint32* value) {
316 SkipSpaces(&str);
317 if (!isdigit(SafeFirstChar(str))) return false;
318
319 int64 result = 0;
320 do {
321 result = result * 10 + SafeFirstChar(str) - '0';
322 if (result > kuint32max) {
323 return false;
324 }
325 str.remove_prefix(1);
326 } while (isdigit(SafeFirstChar(str)));
327
328 SkipSpaces(&str);
329 if (!str.empty()) return false;
330
331 *value = static_cast<uint32>(result);
332 return true;
333}
334
335bool safe_strtof(StringPiece str, float* value) {
336 int processed_characters_count = -1;

Callers 6

ValidateHostPortPairFunction · 0.85
ReadInfoFileFunction · 0.85
ValidateHostPortPairFunction · 0.85
TESTFunction · 0.85
ProtoParseNumericFunction · 0.85
ValidateHostPortPairFunction · 0.85

Calls 3

SkipSpacesFunction · 0.85
SafeFirstCharFunction · 0.85
emptyMethod · 0.45

Tested by 2

ValidateHostPortPairFunction · 0.68
TESTFunction · 0.68