[core] Add uint32_to_str helper and use in preferences (#15597)
This commit is contained in:
1 parent
5ba8c644e4
commit
cf01163c8c
6 files changed
+170
-16
No files matched your search
@@ -380,6 +380,20 @@ static char *format_hex_internal(char *buffer, size_t buffer_size, const uint8_t
|
||||
return buffer;
|
||||
}
|
||||
|
||||
char *uint32_to_str_unchecked(char *buf, uint32_t val) {
|
||||
if (val == 0) {
|
||||
*buf++ = '0';
|
||||
return buf;
|
||||
}
|
||||
char *start = buf;
|
||||
while (val > 0) {
|
||||
*buf++ = '0' + (val % 10);
|
||||
val /= 10;
|
||||
}
|
||||
std::reverse(start, buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
char *format_hex_to(char *buffer, size_t buffer_size, const uint8_t *data, size_t length) {
|
||||
return format_hex_internal(buffer, buffer_size, data, length, 0, 'a');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user