More vvp EOS memory cleanup.

This patch cleans up callbacks for arrays, named events and
real variables. It also cleans up the decimal index constants
for net array words.
This commit is contained in:
Cary R 2009-01-30 18:36:07 -08:00 committed by Stephen Williams
parent d2f4edbfbd
commit 3f0b798ef6
6 changed files with 48 additions and 11 deletions

View File

@ -1513,25 +1513,43 @@ void memory_delete(vpiHandle item)
if (arr->vals_words) delete [] (arr->vals_words-1);
if (arr->vals4) {
// Delete the individual words?
// constant_delete(handle)?
delete arr->vals4;
// Delete the individual words.
// constant_delete(handle)
}
if (arr->valsr) {
// Delete the individual words?
// constant_delete(handle)?
delete arr->valsr;
// Delete the individual words.
// constant_delete(handle)
}
if (arr->nets) {
for (unsigned idx = 0; idx < arr->array_count; idx += 1) {
if (struct __vpiSignal*sig =
vpip_signal_from_handle(arr->nets[idx])) {
// Delete the individual words?
constant_delete(sig->id.index);
/* These should only be the real words. */
} else {
assert(arr->nets[idx]->vpi_type->type_code ==
vpiRealVar);
struct __vpiRealVar *sig = (struct __vpiRealVar *)
arr->nets[idx];
constant_delete(sig->id.index);
// Why are only the real words still here?
// Delete the individual words.
// constant_delete(handle)
free(arr->nets[idx]);
}
}
free(arr->nets);
}
while (arr->vpi_callbacks) {
struct __vpiCallback*tmp = arr->vpi_callbacks->next;
delete_vpi_callback(arr->vpi_callbacks);
arr->vpi_callbacks = tmp;
}
free(arr);
}

View File

@ -783,6 +783,14 @@ void compile_named_event(char*label, char*name)
#ifdef CHECK_WITH_VALGRIND
void named_event_delete(struct __vpiHandle*handle)
{
free(handle);
struct __vpiNamedEvent *obj = (struct __vpiNamedEvent *) handle;
while (obj->callbacks) {
struct __vpiCallback*tmp = obj->callbacks->next;
delete_vpi_callback(obj->callbacks);
obj->callbacks = tmp;
}
free(obj);
}
#endif

View File

@ -520,7 +520,7 @@ void vvp_vpi_callback::add_vpi_callback(__vpiCallback*cb)
void vvp_vpi_callback::clear_all_callbacks()
{
while (vpi_callbacks_) {
__vpiCallback*tmp = vpi_callbacks_->next;
struct __vpiCallback*tmp = vpi_callbacks_->next;
delete_vpi_callback(vpi_callbacks_);
vpi_callbacks_ = tmp;
}

View File

@ -226,3 +226,15 @@ vpiHandle vpip_make_real_var(const char*name, vvp_net_t*net)
return &obj->base;
}
#ifdef CHECK_WITH_VALGRIND
void real_delete(vpiHandle item)
{
struct __vpiRealVar*obj = (struct __vpiRealVar*) item;
vvp_fun_signal_real*fun = (vvp_fun_signal_real*) obj->net->fun;
fun->clear_all_callbacks();
free(obj);
}
#endif

View File

@ -65,7 +65,6 @@ static void delete_sub_scopes(struct __vpiScope *scope)
vthreads_delete(lscope->threads);
delete (scope->intern)[idx];
break;
case vpiIntegerVar:
break;
case vpiMemory:
@ -75,7 +74,6 @@ static void delete_sub_scopes(struct __vpiScope *scope)
/* The destination ModPath is cleaned up later. */
free((scope->intern)[idx]);
break;
break;
case vpiNamedEvent:
named_event_delete((scope->intern)[idx]);
break;
@ -87,7 +85,7 @@ static void delete_sub_scopes(struct __vpiScope *scope)
parameter_delete((scope->intern)[idx]);
break;
case vpiRealVar:
free((scope->intern)[idx]);
real_delete((scope->intern)[idx]);
break;
default:
fprintf(stderr, "Need support for type: %d\n",

View File

@ -45,6 +45,7 @@ extern void memory_delete(struct __vpiHandle *item);
extern void named_event_delete(struct __vpiHandle *item);
extern void parameter_delete(struct __vpiHandle *item);
extern void signal_delete(struct __vpiHandle *item);
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);