From da7c246605d49afe6c2b46133fb15799ec54e8c6 Mon Sep 17 00:00:00 2001 From: schnorr Date: Mon, 20 Dec 2010 16:50:11 +0000 Subject: [PATCH] [trace] fix on use of dynar, storing pointers in it, have to correctly cast when getting them back details: - this fix a segfault when destroying containers and freeing memory git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9302 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/instr/instr_routing.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/instr/instr_routing.c b/src/instr/instr_routing.c index bc53ae6e51..e490915eec 100644 --- a/src/instr/instr_routing.c +++ b/src/instr/instr_routing.c @@ -446,28 +446,28 @@ static void recursiveGraphExtraction (container_t container) static void instr_routing_parse_start_AS () { if (rootContainer == NULL){ - currentContainer = xbt_dynar_new (sizeof(s_container_t), NULL); + currentContainer = xbt_dynar_new (sizeof(container_t), NULL); allContainers = xbt_dict_new (); allLinkTypes = xbt_dynar_new (sizeof(s_type_t), NULL); allHostTypes = xbt_dynar_new (sizeof(s_type_t), NULL); rootContainer = newContainer ("0", INSTR_AS, NULL); - xbt_dynar_push (currentContainer, rootContainer); + xbt_dynar_push (currentContainer, &rootContainer); if (TRACE_smpi_is_enabled()) { if (!TRACE_smpi_is_grouped()){ - container_t father = xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1); + container_t father = *(container_t*)xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1); type_t mpi = getContainerType("MPI", father->type); getStateType ("MPI_STATE", mpi); getLinkType ("MPI_LINK", rootType, mpi, mpi); } } } - container_t father = xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1); + container_t father = *(container_t*)xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1); container_t new = newContainer (A_surfxml_AS_id, INSTR_AS, father); //push - xbt_dynar_push (currentContainer, new); + xbt_dynar_push (currentContainer, &new); } static void instr_routing_parse_end_AS () @@ -477,7 +477,7 @@ static void instr_routing_parse_end_AS () static void instr_routing_parse_start_link () { - container_t father = xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1); + container_t father = *(container_t*)xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1); container_t new = newContainer (A_surfxml_link_id, INSTR_LINK, father); type_t bandwidth = getVariableType ("bandwidth", NULL, new->type); @@ -495,7 +495,7 @@ static void instr_routing_parse_end_link () static void instr_routing_parse_start_host () { - container_t father = xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1); + container_t father = *(container_t*)xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1); container_t new = newContainer (A_surfxml_host_id, INSTR_HOST, father); type_t power = getVariableType ("power", NULL, new->type); @@ -531,7 +531,7 @@ static void instr_routing_parse_end_host () static void instr_routing_parse_start_router () { - container_t father = xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1); + container_t father = *(container_t*)xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1); newContainer (A_surfxml_router_id, INSTR_ROUTER, father); } @@ -541,6 +541,7 @@ static void instr_routing_parse_end_router () static void instr_routing_parse_end_platform () { + xbt_dynar_free(¤tContainer); currentContainer = NULL; recursiveGraphExtraction (rootContainer); platform_created = 1; -- 2.20.1