Clean up user function calls from thread space.

This patch adds cleanup code that cleans up the memory that is
allocated by the of_EXEC_UFUNC command. This knocks a few more
files off the valgrind list.
This commit is contained in:
Cary R 2009-10-13 18:03:39 -07:00 committed by Stephen Williams
parent 8abf303753
commit 02ca7fe7fc
4 changed files with 18 additions and 1 deletions

View File

@ -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;
}

View File

@ -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 <malloc.h>
#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

View File

@ -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);

View File

@ -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);