From 3dd2c74ebea22ca76f070ee61a7248794b0b28d0 Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 19 Nov 2008 14:41:25 -0800 Subject: [PATCH] V0.8: 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. --- vvp/vpi_priv.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/vvp/vpi_priv.cc b/vvp/vpi_priv.cc index d3f8da9ce..170257b5b 100644 --- a/vvp/vpi_priv.cc +++ b/vvp/vpi_priv.cc @@ -401,6 +401,22 @@ static void vpip_put_value_callback(vvp_gen_event_t eobj, unsigned char) vpip_put_value_event*put = (vpip_put_value_event*)eobj; put->handle->vpi_type->vpi_put_value_ (put->handle, &put->value); + switch (put->value.format) { + /* Free the copied string. */ + case vpiBinStrVal: + case vpiOctStrVal: + case vpiDecStrVal: + case vpiHexStrVal: + case vpiStringVal: + free(put->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, @@ -432,6 +448,22 @@ vpiHandle vpi_put_value(vpiHandle obj, s_vpi_value*vp, vpip_put_value_event*put = new vpip_put_value_event; put->handle = obj; 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->run = &vpip_put_value_callback; schedule_generic(put, 0, dly, false); return 0;