diff --git a/include/jtag/data_register.h b/include/jtag/data_register.h index 61fcf2c2..71a45372 100644 --- a/include/jtag/data_register.h +++ b/include/jtag/data_register.h @@ -27,12 +27,14 @@ #include +#define MAXLEN_DATA_REGISTER 10 + typedef struct data_register data_register; struct data_register { - char *name; /* (public) register name */ - tap_register *in; /* (public) register value clocked in */ - tap_register *out; /* (public) register value clocked out */ + char name[MAXLEN_DATA_REGISTER + 1]; /* (public) register name */ + tap_register *in; /* (public) register value clocked in */ + tap_register *out; /* (public) register value clocked out */ data_register *next; }; diff --git a/jtag/src/part/data_register.c b/jtag/src/part/data_register.c index 6824a3cb..aa3dc64d 100644 --- a/jtag/src/part/data_register.c +++ b/jtag/src/part/data_register.c @@ -39,11 +39,10 @@ data_register_alloc( const char *name, int len ) if (!dr) return NULL; - dr->name = strdup( name ); - if (!dr->name) { - free( dr ); - return NULL; - } + if (strlen( name ) > MAXLEN_DATA_REGISTER) + printf( "Warning: Data register too long\n" ); + strncpy( dr->name, name, MAXLEN_DATA_REGISTER ); + dr->name[MAXLEN_DATA_REGISTER] = '\0'; dr->in = register_alloc( len ); dr->out = register_alloc( len ); @@ -66,7 +65,6 @@ data_register_free( data_register *dr ) if (!dr) return; - free( dr->name ); register_free( dr->in ); register_free( dr->out ); free( dr );