Added function register_duplicate(). Fixed possible segfault in register_get_string().

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@108 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Marcel Telka 23 years ago
parent 55b88e2752
commit cd96faedba

@ -32,6 +32,7 @@ typedef struct tap_register {
} tap_register;
tap_register *register_alloc( int len );
tap_register *register_duplicate( tap_register *tr );
void register_free( tap_register *tr );
tap_register *register_fill( tap_register *tr, int val );
const char *register_get_string( tap_register *tr );

@ -58,6 +58,15 @@ register_alloc( int len )
return tr;
}
tap_register *
register_duplicate( tap_register *tr )
{
if (!tr)
return NULL;
return register_init( register_alloc( tr->len ), register_get_string( tr ) );
}
void
register_free( tap_register *tr )
{
@ -80,12 +89,13 @@ register_fill( tap_register *tr, int val )
const char *
register_get_string( tap_register *tr )
{
if (tr) {
int i;
int i;
for (i = 0; i < tr->len; i++)
tr->string[tr->len - 1 - i] = (tr->data[i] & 1) ? '1' : '0';
}
if (!tr)
return NULL;
for (i = 0; i < tr->len; i++)
tr->string[tr->len - 1 - i] = (tr->data[i] & 1) ? '1' : '0';
return tr->string;
}

Loading…
Cancel
Save