Correctly cleanup class and string object when using valgrind
This commit is contained in:
parent
c1566bc02b
commit
196df151aa
|
|
@ -20,6 +20,9 @@
|
|||
# include "version_base.h"
|
||||
# include "vpi_priv.h"
|
||||
# include "schedule.h"
|
||||
#ifdef CHECK_WITH_VALGRIND
|
||||
# include "vvp_cleanup.h"
|
||||
#endif
|
||||
# include <cstdio>
|
||||
# include <cstdarg>
|
||||
# include <cstring>
|
||||
|
|
@ -69,6 +72,13 @@ __vpiBaseVar::__vpiBaseVar(__vpiScope*scope, const char*name, vvp_net_t*net)
|
|||
{
|
||||
}
|
||||
|
||||
#ifdef CHECK_WITH_VALGRIND
|
||||
__vpiBaseVar::~__vpiBaseVar()
|
||||
{
|
||||
vvp_net_delete(net_);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The default behavior for the vpi_free_object to an object is to
|
||||
* suppress the actual operation. This is because handles are
|
||||
|
|
|
|||
|
|
@ -487,6 +487,9 @@ class __vpiBaseVar : public __vpiHandle {
|
|||
|
||||
public:
|
||||
__vpiBaseVar(__vpiScope*scope, const char*name, vvp_net_t*net);
|
||||
#ifdef CHECK_WITH_VALGRIND
|
||||
~__vpiBaseVar();
|
||||
#endif
|
||||
|
||||
inline vvp_net_t* get_net() const { return net_; }
|
||||
|
||||
|
|
|
|||
|
|
@ -111,9 +111,17 @@ void vvp_net_delete(vvp_net_t *item)
|
|||
if (vvp_udp_fun_core*tmp = dynamic_cast<vvp_udp_fun_core*> (item->fun)) {
|
||||
udp_map[tmp] = true;
|
||||
}
|
||||
if (resolv_core*tmp = dynamic_cast<resolv_core*>(item->fun)) {
|
||||
if (resolv_core*tmp = dynamic_cast<resolv_core*> (item->fun)) {
|
||||
resolv_map[tmp] = true;
|
||||
}
|
||||
/* Only delete static object variables. */
|
||||
if (vvp_fun_signal_object_sa*tmp = dynamic_cast<vvp_fun_signal_object_sa*> (item->fun)) {
|
||||
delete tmp;
|
||||
}
|
||||
/* Only delete static string variables. */
|
||||
if (vvp_fun_signal_string_sa*tmp = dynamic_cast<vvp_fun_signal_string_sa*> (item->fun)) {
|
||||
delete tmp;
|
||||
}
|
||||
}
|
||||
|
||||
void vvp_net_pool_delete()
|
||||
|
|
|
|||
Loading…
Reference in New Issue