Skip to content

Commit

Permalink
Update the valgrind cleanup code to handle most tri constructs
Browse files Browse the repository at this point in the history
  • Loading branch information
caryr committed Jan 2, 2013
1 parent 84a24f2 commit f5717a6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion vvp/vvp_net.cc
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stephen Williams (steve@icarus.com) * Copyright (c) 2004-2013 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
Expand Down Expand Up @@ -90,6 +90,7 @@ void* vvp_net_t::operator new (size_t size)
static map<vvp_net_t*, bool> vvp_net_map; static map<vvp_net_t*, bool> vvp_net_map;
static map<sfunc_core*, bool> sfunc_map; static map<sfunc_core*, bool> sfunc_map;
static map<vvp_udp_fun_core*, bool> udp_map; static map<vvp_udp_fun_core*, bool> udp_map;
static map<resolv_core*, bool> resolv_map;
static vvp_net_t **local_net_pool = 0; static vvp_net_t **local_net_pool = 0;
static unsigned local_net_pool_count = 0; static unsigned local_net_pool_count = 0;


Expand All @@ -110,6 +111,9 @@ void vvp_net_delete(vvp_net_t *item)
if (vvp_udp_fun_core*tmp = dynamic_cast<vvp_udp_fun_core*> (item->fun)) { if (vvp_udp_fun_core*tmp = dynamic_cast<vvp_udp_fun_core*> (item->fun)) {
udp_map[tmp] = true; udp_map[tmp] = true;
} }
if (resolv_core*tmp = dynamic_cast<resolv_core*>(item->fun)) {
resolv_map[tmp] = true;
}
} }


void vvp_net_pool_delete() void vvp_net_pool_delete()
Expand Down Expand Up @@ -142,6 +146,12 @@ void vvp_net_pool_delete()
} }
udp_map.clear(); udp_map.clear();


map<resolv_core*, bool>::iterator riter;
for (riter = resolv_map.begin(); riter != resolv_map.end(); ++ riter ) {
delete riter->first;
}
resolv_map.clear();

if (RUNNING_ON_VALGRIND && (vvp_nets_del != count_vvp_nets)) { if (RUNNING_ON_VALGRIND && (vvp_nets_del != count_vvp_nets)) {
fflush(NULL); fflush(NULL);
VALGRIND_PRINTF("Error: vvp missed deleting %ld of %lu net(s).", VALGRIND_PRINTF("Error: vvp missed deleting %ld of %lu net(s).",
Expand Down Expand Up @@ -244,7 +254,9 @@ void vvp_net_t::count_drivers(unsigned idx, unsigned counts[4])


void vvp_net_fun_t::operator delete(void*) void vvp_net_fun_t::operator delete(void*)
{ {
#ifndef CHECK_WITH_VALGRIND
assert(0); assert(0);
#endif
} }




Expand Down

0 comments on commit f5717a6

Please sign in to comment.