temp sync broken
This commit is contained in:
@@ -21,4 +21,19 @@ void hexdump (const char *label, const uint8_t *data, size_t len) {
|
||||
}
|
||||
printf ("\n");
|
||||
}
|
||||
}
|
||||
|
||||
void hexdump_compact(const uint8_t* data, size_t len, char* out, size_t out_size) {
|
||||
size_t pos = 0;
|
||||
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
if (pos + 2 >= out_size) break; // make sure we don¡¯t overflow
|
||||
snprintf(out + pos, 3, "%02x", data[i]); // 2 chars + null terminator
|
||||
pos += 2;
|
||||
}
|
||||
|
||||
if (pos < out_size)
|
||||
out[pos] = '\0';
|
||||
else
|
||||
out[out_size - 1] = '\0'; // ensure null termination
|
||||
}
|
||||
@@ -6,4 +6,6 @@
|
||||
#include "stdint.h"
|
||||
void hexdump (const char *label, const uint8_t *data, size_t len);
|
||||
|
||||
void hexdump_compact(const uint8_t* data, size_t len, char* out, size_t out_size);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user