Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Optimize Dbhexdump #2514

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions armsrc/dbprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,27 @@ void Dbprintf(const char *fmt, ...) {
// prints HEX & ASCII
void Dbhexdump(int len, const uint8_t *d, bool bAsci) {
#if DEBUG
char ascii[17];

while (len > 0) {

int l = (len > 16) ? 16 : len;

memcpy(ascii, d, l);
ascii[l] = 0;
if (bAsci) {
char ascii[17];

memcpy(ascii, d, l);
ascii[l] = 0;

// filter safe ascii
for (int i = 0; i < l; i++) {
if (ascii[i] < 32 || ascii[i] > 126) {
ascii[i] = '.';
// filter safe ascii
for (int i = 0; i < l; i++) {
if (ascii[i] < 32 || ascii[i] > 126) {
ascii[i] = '.';
}
}
}

if (bAsci)
Dbprintf("%-8s %*D", ascii, l, d, " ");
else
} else {
Dbprintf("%*D", l, d, " ");
}

len -= 16;
d += 16;
Expand Down
Loading