Remove some valgrind warnings and a few errors
Cleanup a few more of the new constructs and fix free/delete mismatches.
This commit is contained in:
parent
317e53e784
commit
3fa7b3f05a
|
|
@ -47,7 +47,7 @@ void compile_class_start(char*lab, char*nam, unsigned ntype)
|
||||||
assert(compile_class == 0);
|
assert(compile_class == 0);
|
||||||
compile_class = new class_type(nam, ntype);
|
compile_class = new class_type(nam, ntype);
|
||||||
compile_vpi_symbol(lab, compile_class);
|
compile_vpi_symbol(lab, compile_class);
|
||||||
delete[]lab;
|
free(lab);
|
||||||
delete[]nam;
|
delete[]nam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,4 +64,3 @@ void compile_class_done(void)
|
||||||
scope->classes[compile_class->class_name()] = compile_class;
|
scope->classes[compile_class->class_name()] = compile_class;
|
||||||
compile_class = 0;
|
compile_class = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2011 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2001-2012 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -117,6 +117,10 @@ void codespace_delete(void)
|
||||||
exec_ufunc_delete((cur+idx));
|
exec_ufunc_delete((cur+idx));
|
||||||
} else if ((cur+idx)->opcode == &of_FILE_LINE) {
|
} else if ((cur+idx)->opcode == &of_FILE_LINE) {
|
||||||
delete((cur+idx)->handle);
|
delete((cur+idx)->handle);
|
||||||
|
} else if (((cur+idx)->opcode == &of_CONCATI_STR) ||
|
||||||
|
((cur+idx)->opcode == &of_NEW_DARRAY) ||
|
||||||
|
((cur+idx)->opcode == &of_PUSHI_STR)) {
|
||||||
|
delete [] ((cur+idx)->text);
|
||||||
}
|
}
|
||||||
if (count_opcodes == 0) break;
|
if (count_opcodes == 0) break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,7 @@ static void final_cleanup()
|
||||||
dec_str_delete();
|
dec_str_delete();
|
||||||
modpath_delete();
|
modpath_delete();
|
||||||
vpi_handle_delete();
|
vpi_handle_delete();
|
||||||
|
vpi_stack_delete();
|
||||||
udp_defns_delete();
|
udp_defns_delete();
|
||||||
island_delete();
|
island_delete();
|
||||||
signal_pool_delete();
|
signal_pool_delete();
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,10 @@
|
||||||
|
|
||||||
# include "compile.h"
|
# include "compile.h"
|
||||||
# include "vpi_priv.h"
|
# include "vpi_priv.h"
|
||||||
|
# include "config.h"
|
||||||
|
#ifdef CHECK_WITH_VALGRIND
|
||||||
|
# include "vvp_cleanup.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
__vpiCobjectVar::__vpiCobjectVar(__vpiScope*sc, const char*na, vvp_net_t*ne)
|
__vpiCobjectVar::__vpiCobjectVar(__vpiScope*sc, const char*na, vvp_net_t*ne)
|
||||||
: __vpiBaseVar(sc, na, ne)
|
: __vpiBaseVar(sc, na, ne)
|
||||||
|
|
@ -48,3 +52,11 @@ vpiHandle vpip_make_cobject_var(const char*name, vvp_net_t*net)
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CHECK_WITH_VALGRIND
|
||||||
|
void class_delete(vpiHandle item)
|
||||||
|
{
|
||||||
|
class __vpiCobjectVar*obj = dynamic_cast<__vpiCobjectVar*>(item);
|
||||||
|
delete obj;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -76,3 +76,11 @@ vpiHandle vpip_make_darray_var(const char*name, vvp_net_t*net)
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CHECK_WITH_VALGRIND
|
||||||
|
void darray_delete(vpiHandle item)
|
||||||
|
{
|
||||||
|
class __vpiDarrayVar*obj = dynamic_cast<__vpiDarrayVar*>(item);
|
||||||
|
delete obj;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -60,10 +60,11 @@ extern vpiHandle vpip_build_file_line(char*description,
|
||||||
#ifdef CHECK_WITH_VALGRIND
|
#ifdef CHECK_WITH_VALGRIND
|
||||||
#define _vpiFromThr 0x1000001
|
#define _vpiFromThr 0x1000001
|
||||||
# define _vpiNoThr 0
|
# define _vpiNoThr 0
|
||||||
# define _vpiVThr 1
|
# define _vpiString 1
|
||||||
# define _vpiWord 2
|
# define _vpiVThr 2
|
||||||
# define _vpi_at_PV 3
|
# define _vpiWord 3
|
||||||
# define _vpi_at_A 4
|
# define _vpi_at_PV 4
|
||||||
|
# define _vpi_at_A 5
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,13 @@ static void delete_sub_scopes(struct __vpiScope *scope)
|
||||||
port_delete((scope->intern)[idx]);
|
port_delete((scope->intern)[idx]);
|
||||||
break;
|
break;
|
||||||
case vpiStringVar:
|
case vpiStringVar:
|
||||||
|
string_delete((scope->intern)[idx]);
|
||||||
|
break;
|
||||||
|
case vpiClassVar:
|
||||||
|
class_delete((scope->intern)[idx]);
|
||||||
|
break;
|
||||||
case vpiRegArray:
|
case vpiRegArray:
|
||||||
|
darray_delete((scope->intern)[idx]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Need support for type: %d\n",
|
fprintf(stderr, "Need support for type: %d\n",
|
||||||
|
|
|
||||||
|
|
@ -82,3 +82,11 @@ vpiHandle vpip_make_string_var(const char*name, vvp_net_t*net)
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CHECK_WITH_VALGRIND
|
||||||
|
void string_delete(vpiHandle item)
|
||||||
|
{
|
||||||
|
class __vpiStringVar*obj = dynamic_cast<__vpiStringVar*>(item);
|
||||||
|
delete obj;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -843,6 +843,9 @@ void vpi_call_delete(vpiHandle item)
|
||||||
case _vpiNoThr:
|
case _vpiNoThr:
|
||||||
constant_delete(obj->args[arg]);
|
constant_delete(obj->args[arg]);
|
||||||
break;
|
break;
|
||||||
|
case _vpiString:
|
||||||
|
thread_string_delete(obj->args[arg]);
|
||||||
|
break;
|
||||||
case _vpiVThr:
|
case _vpiVThr:
|
||||||
thread_vthr_delete(obj->args[arg]);
|
thread_vthr_delete(obj->args[arg]);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -660,6 +660,10 @@ int __vpiVThrStrStack::vpi_get(int code)
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case vpiConstType:
|
case vpiConstType:
|
||||||
return vpiStringConst;
|
return vpiStringConst;
|
||||||
|
#ifdef CHECK_WITH_VALGRIND
|
||||||
|
case _vpiFromThr:
|
||||||
|
return _vpiString;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -698,3 +702,26 @@ vpiHandle vpip_make_vthr_str_stack(unsigned depth)
|
||||||
class __vpiVThrStrStack*obj = new __vpiVThrStrStack(depth);
|
class __vpiVThrStrStack*obj = new __vpiVThrStrStack(depth);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CHECK_WITH_VALGRIND
|
||||||
|
static map<vpiHandle, bool> stack_map;
|
||||||
|
|
||||||
|
void thread_string_delete(vpiHandle item)
|
||||||
|
{
|
||||||
|
stack_map[item] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void thread_string_delete_real(vpiHandle item)
|
||||||
|
{
|
||||||
|
class __vpiVThrStrStack*obj = dynamic_cast<__vpiVThrStrStack*>(item);
|
||||||
|
delete obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vpi_stack_delete()
|
||||||
|
{
|
||||||
|
map<vpiHandle, bool>::iterator iter;
|
||||||
|
for (iter = stack_map.begin(); iter != stack_map.end(); ++ iter ) {
|
||||||
|
thread_string_delete_real(iter->first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -36,19 +36,24 @@ extern void root_table_delete(void);
|
||||||
extern void signal_pool_delete(void);
|
extern void signal_pool_delete(void);
|
||||||
extern void udp_defns_delete(void);
|
extern void udp_defns_delete(void);
|
||||||
extern void vpi_handle_delete(void);
|
extern void vpi_handle_delete(void);
|
||||||
|
extern void vpi_stack_delete(void);
|
||||||
extern void vvp_net_pool_delete(void);
|
extern void vvp_net_pool_delete(void);
|
||||||
extern void ufunc_pool_delete(void);
|
extern void ufunc_pool_delete(void);
|
||||||
|
|
||||||
extern void A_delete(class __vpiHandle *item);
|
extern void A_delete(class __vpiHandle *item);
|
||||||
extern void PV_delete(class __vpiHandle *item);
|
extern void PV_delete(class __vpiHandle *item);
|
||||||
|
extern void class_delete(class __vpiHandle *item);
|
||||||
extern void constant_delete(class __vpiHandle *item);
|
extern void constant_delete(class __vpiHandle *item);
|
||||||
extern void contexts_delete(struct __vpiScope *scope);
|
extern void contexts_delete(struct __vpiScope *scope);
|
||||||
|
extern void darray_delete(class __vpiHandle *item);
|
||||||
extern void enum_delete(class __vpiHandle *item);
|
extern void enum_delete(class __vpiHandle *item);
|
||||||
extern void memory_delete(class __vpiHandle *item);
|
extern void memory_delete(class __vpiHandle *item);
|
||||||
extern void named_event_delete(class __vpiHandle *item);
|
extern void named_event_delete(class __vpiHandle *item);
|
||||||
extern void parameter_delete(class __vpiHandle *item);
|
extern void parameter_delete(class __vpiHandle *item);
|
||||||
extern void signal_delete(class __vpiHandle *item);
|
extern void signal_delete(class __vpiHandle *item);
|
||||||
extern void real_delete(class __vpiHandle *item);
|
extern void real_delete(class __vpiHandle *item);
|
||||||
|
extern void string_delete(class __vpiHandle *item);
|
||||||
|
extern void thread_string_delete(class __vpiHandle *item);
|
||||||
extern void thread_vthr_delete(class __vpiHandle *item);
|
extern void thread_vthr_delete(class __vpiHandle *item);
|
||||||
extern void thread_word_delete(class __vpiHandle *item);
|
extern void thread_word_delete(class __vpiHandle *item);
|
||||||
extern void vpi_call_delete(class __vpiHandle *item);
|
extern void vpi_call_delete(class __vpiHandle *item);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue