For scheduled put values save the string and free it after the put.
Users expect that vpi_put_value() will keep a copy of the string that is passed to it. This patch implements this buy copying the string and then freeing it after the actual put_value call.
This commit is contained in:
parent
a288b0180c
commit
c9077bd0be
|
|
@ -677,6 +677,22 @@ struct vpip_put_value_event : vvp_gen_event_s {
|
||||||
void vpip_put_value_event::run_run()
|
void vpip_put_value_event::run_run()
|
||||||
{
|
{
|
||||||
handle->vpi_type->vpi_put_value_ (handle, &value, flags);
|
handle->vpi_type->vpi_put_value_ (handle, &value, flags);
|
||||||
|
switch (value.format) {
|
||||||
|
/* Free the copied string. */
|
||||||
|
case vpiBinStrVal:
|
||||||
|
case vpiOctStrVal:
|
||||||
|
case vpiDecStrVal:
|
||||||
|
case vpiHexStrVal:
|
||||||
|
case vpiStringVal:
|
||||||
|
free(value.value.str);
|
||||||
|
break;
|
||||||
|
/* If these are every copied then free them too. */
|
||||||
|
case vpiTimeVal:
|
||||||
|
case vpiVectorVal:
|
||||||
|
case vpiStrengthVal:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vpiHandle vpi_put_value(vpiHandle obj, s_vpi_value*vp,
|
vpiHandle vpi_put_value(vpiHandle obj, s_vpi_value*vp,
|
||||||
|
|
@ -720,6 +736,22 @@ vpiHandle vpi_put_value(vpiHandle obj, s_vpi_value*vp,
|
||||||
vpip_put_value_event*put = new vpip_put_value_event;
|
vpip_put_value_event*put = new vpip_put_value_event;
|
||||||
put->handle = obj;
|
put->handle = obj;
|
||||||
put->value = *vp;
|
put->value = *vp;
|
||||||
|
switch (put->value.format) {
|
||||||
|
/* If this is scheduled make a copy of the string. */
|
||||||
|
case vpiBinStrVal:
|
||||||
|
case vpiOctStrVal:
|
||||||
|
case vpiDecStrVal:
|
||||||
|
case vpiHexStrVal:
|
||||||
|
case vpiStringVal:
|
||||||
|
put->value.value.str = strdup(put->value.value.str);
|
||||||
|
break;
|
||||||
|
/* Do these also need to be copied? */
|
||||||
|
case vpiTimeVal:
|
||||||
|
case vpiVectorVal:
|
||||||
|
case vpiStrengthVal:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
put->flags = flags;
|
put->flags = flags;
|
||||||
schedule_generic(put, dly, false);
|
schedule_generic(put, dly, false);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue