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

Function from_number

common/amount.c:138–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138static bool from_number(u64 *res, const char *s, size_t len, int tens_factor)
139{
140 if (len == 0)
141 return false;
142
143 *res = 0;
144 for (size_t i = 0; i < len; i++) {
145 if (mul_overflows_u64(*res, 10))
146 return false;
147 *res *= 10;
148 assert(cisdigit(s[i]));
149 if (add_overflows_u64(*res, s[i] - '0'))
150 return false;
151 *res += s[i] - '0';
152 }
153 while (tens_factor > 0) {
154 if (mul_overflows_u64(*res, 10))
155 return false;
156 *res *= 10;
157 tens_factor--;
158 }
159 return true;
160}
161
162static bool from_numbers(u64 *res,
163 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