diff --git a/vvp/codes.cc b/vvp/codes.cc index 54bbd4d6c..ddf0e27ea 100644 --- a/vvp/codes.cc +++ b/vvp/codes.cc @@ -107,6 +107,8 @@ void codespace_delete(void) count_opcodes -= 1; if ((cur+idx)->opcode == &of_VPI_CALL) { vpi_call_delete((cur+idx)->handle); + } else if ((cur+idx)->opcode == &of_EXEC_UFUNC) { + exec_ufunc_delete((cur+idx)); } if (count_opcodes == 0) break; } diff --git a/vvp/ufunc.cc b/vvp/ufunc.cc index c74ef7b65..ff2a10508 100644 --- a/vvp/ufunc.cc +++ b/vvp/ufunc.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2008 Stephen Williams (steve@icarus.com) + * Copyright (c) 2002-2009 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -25,6 +25,9 @@ # include "vvp_net_sig.h" # include "vthread.h" # include "schedule.h" +#ifdef CHECK_WITH_VALGRIND +# include "vvp_cleanup.h" +#endif #ifdef HAVE_MALLOC_H # include #endif @@ -56,6 +59,7 @@ ufunc_core::ufunc_core(unsigned owid, vvp_net_t*ptr, ufunc_core::~ufunc_core() { + delete [] ports_; } /* @@ -198,3 +202,10 @@ void compile_ufunc(char*label, char*code, unsigned wid, free(argv); free(portv); } + +#ifdef CHECK_WITH_VALGRIND +void exec_ufunc_delete(vvp_code_t euf_code) +{ + delete euf_code->ufunc_core_ptr; +} +#endif diff --git a/vvp/vvp_cleanup.h b/vvp/vvp_cleanup.h index 1dcc30ab1..b6ac04a47 100644 --- a/vvp/vvp_cleanup.h +++ b/vvp/vvp_cleanup.h @@ -50,6 +50,7 @@ extern void real_delete(struct __vpiHandle *item); extern void thread_vthr_delete(struct __vpiHandle *item); extern void thread_word_delete(struct __vpiHandle *item); extern void vpi_call_delete(struct __vpiHandle *item); +extern void exec_ufunc_delete(vvp_code_t euf_code); extern void vthreads_delete(vthread_t base); extern void vvp_net_delete(vvp_net_t *item); diff --git a/vvp/vvp_net.h b/vvp/vvp_net.h index 0b8e979e5..283b88c7f 100644 --- a/vvp/vvp_net.h +++ b/vvp/vvp_net.h @@ -1347,6 +1347,9 @@ class vvp_wide_fun_core : public vvp_net_fun_t { public: vvp_wide_fun_core(vvp_net_t*net, unsigned nports); virtual ~vvp_wide_fun_core(); + // These objects are not perm allocated. + void* operator new(std::size_t size) { return ::new char[size]; } + void operator delete(void* ptr) { ::delete[]((char*)ptr); } protected: void propagate_vec4(const vvp_vector4_t&bit, vvp_time64_t delay =0);