Browse Source

fixed array initialisation bug

master
Avril 1 year ago
parent
commit
f7997ca157
Signed by: flanchan GPG Key ID: 284488987C31F630
  1. 3
      include/hex.hpp
  2. 10
      src/hex.cpp

3
include/hex.hpp

@ -31,6 +31,9 @@ namespace hv {
{
int pos = (x & 0xFF) * 2;
char ch = lut[pos];
#ifdef DEBUG
if ( (i*2+1) >=16) std::terminate();
#endif
s[i * 2] = ch;
ch = lut[pos + 1];

10
src/hex.cpp

@ -88,18 +88,20 @@ namespace hv {
#define S
#define P_EX(n, buf) print_exact(buf)
#endif
char posbuf[3 + 16 + 2] = { '0' };
char posbuf[3 + 16 + 2];
posbuf[0] = '\n';
posbuf[1] = '0';
posbuf[2] = 'x';
#ifdef DEBUG
std::memset(posbuf+3, '0', 16);
#endif
posbuf[3 + 16] = ' ';
posbuf[3 + 16 + 1] = ' ';
u64_to_hex(offset, posbuf+3);
prints(posbuf+1);
char hxbuf[3] = { ' ' };
char hxbuf[3] = { ' ', ' ', ' ' };
std::size_t i=0;
char r_ascii[2 + ROW_SZ];
r_ascii[0] = ' ';
@ -124,7 +126,7 @@ namespace hv {
{
auto rest = memsize % ROW_SZ;
ascii[rest] = 0;
constexpr const char output[3] = { ' ' };
constexpr const char output[3] = { ' ', ' ', ' ' };
for(std::size_t j=0;j< ROW_SZ - rest;j++)
print_exact(output);

Loading…
Cancel
Save