MCPcopy Create free account
hub / github.com/ElementsProject/lightning / from_number

Function from_number

common/amount.c:151–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151static bool from_number(u64 *res, const char *s, size_t len, int tens_factor)
152{
153 if (len == 0)
154 return false;
155
156 *res = 0;
157 for (size_t i = 0; i < len; i++) {
158 if (mul_overflows_u64(*res, 10))
159 return false;
160 *res *= 10;
161 assert(cisdigit(s[i]));
162 if (add_overflows_u64(*res, s[i] - '0'))
163 return false;
164 *res += s[i] - '0';
165 }
166 while (tens_factor > 0) {
167 if (mul_overflows_u64(*res, 10))
168 return false;
169 *res *= 10;
170 tens_factor--;
171 }
172 return true;
173}
174
175static bool from_numbers(u64 *res,
176 const char *s1, size_t len1, int tens_factor,

Callers 3

from_numbersFunction · 0.85
parse_amount_msatFunction · 0.85
parse_amount_satFunction · 0.85

Calls 3

mul_overflows_u64Function · 0.85
cisdigitFunction · 0.85
add_overflows_u64Function · 0.85

Tested by

no test coverage detected