Added a separator between hex and ascii sides.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8568 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Houdoin 2004-08-14 00:51:02 +00:00
parent 15b8f34b6f
commit 24e9e6005a

View File

@ -6,42 +6,37 @@
#include "dump.h"
// --------------------------------------------------
void dump_memory
(
const char * prefix,
const void * data,
size_t len
)
void dump_memory(const char *prefix, const void *data, size_t len)
{
uint32 i,j;
char text[96]; // only 3*16 + 16 max by line needed
uint8 * byte;
char * ptr;
uint32 i,j;
char text[96]; // only 3*16 + 3 + 16 max by line needed
uint8 *byte;
char *ptr;
byte = (uint8 *) data;
for ( i = 0; i < len; i += 16 )
{
for ( i = 0; i < len; i += 16 ) {
ptr = text;
for ( j = i; j < i+16 ; j++ )
{
for ( j = i; j < i+16 ; j++ ) {
if ( j < len )
sprintf(ptr, "%02x ", byte[j]);
else
sprintf(ptr, " ");
ptr += 3;
};
};
for (j = i; j < len && j < i+16;j++)
{
strcat(ptr, "| ");
ptr += 2;
for (j = i; j < len && j < i+16;j++) {
if ( byte[j] >= 0x20 && byte[j] < 0x7e )
*ptr = byte[j];
else
*ptr = '.';
ptr++;
};
};
*ptr = '\n';
ptr++;
*ptr = '\0';
@ -51,5 +46,5 @@ void dump_memory
dprintf(text);
// next line
};
};
}