Skip to content

Commit 1056f35

Browse files
Deprecate array_hexstr to rather use format_hex from the SDK
1 parent 692a82c commit 1056f35

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/common_utils.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@
2323
#include "lcx_ecfp.h"
2424
#include "lcx_sha3.h"
2525

26-
void array_hexstr(char *strbuf, const void *bin, unsigned int len) {
27-
while (len--) {
28-
*strbuf++ = HEXDIGITS[((*((char *) bin)) >> 4) & 0xF];
29-
*strbuf++ = HEXDIGITS[(*((char *) bin)) & 0xF];
30-
bin = (const void *) ((unsigned int) bin + 1);
31-
}
32-
*strbuf = 0; // EOS
33-
}
34-
3526
uint64_t u64_from_BE(const uint8_t *in, uint8_t size) {
3627
uint8_t i = 0;
3728
uint64_t res = 0;

src/common_utils.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "os.h"
2424
#include "cx.h"
25+
#include "format.h"
2526

2627
#define WEI_TO_ETHER 18
2728

@@ -35,7 +36,15 @@ static const char HEXDIGITS[] = "0123456789abcdef";
3536

3637
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
3738

38-
void array_hexstr(char *strbuf, const void *bin, unsigned int len);
39+
/**
40+
* @deprecated
41+
* See format_hex in SDK
42+
*/
43+
DEPRECATED static inline void array_hexstr(char *strbuf, const void *bin, unsigned int len)
44+
{
45+
// Consider the output buffer is sufficiently large!
46+
format_hex(bin, len, strbuf, (2 * len + 1));
47+
}
3948

4049
uint64_t u64_from_BE(const uint8_t *in, uint8_t size);
4150

0 commit comments

Comments
 (0)