From fec5fff327fcad427d0a399ebc3dbbb35de2852e Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Sat, 31 May 2014 23:08:11 +0200 Subject: [PATCH] Make xbt_free a function-like macro. Use xbt_free_f everywhere a pointer to function is needed. --- examples/msg/properties/msg_prop.c | 4 ++-- examples/simdag/properties/sd_prop.c | 4 ++-- include/smpi/smpi_cocci.h | 4 ++-- include/xbt/sysdep.h | 2 +- src/bindings/java/jmsg_host.c | 2 +- src/instr/instr_config.c | 10 +++++----- src/instr/instr_interface.c | 2 +- src/instr/instr_paje_containers.c | 4 ++-- src/instr/jedule/jedule_platform.c | 2 +- src/smpi/instr_smpi.c | 2 +- src/smpi/smpi_base.c | 2 +- src/smpi/smpi_bench.c | 2 +- src/smpi/smpi_deployment.c | 2 +- src/surf/instr_routing.c | 4 ++-- src/surf/platf_generator.c | 2 +- src/surf/storage_interface.cpp | 2 +- src/surf/storage_n11.cpp | 2 +- src/surf/surf_routing.cpp | 2 +- src/surf/surf_routing_dijkstra.cpp | 8 ++++---- src/surf/surf_routing_floyd.cpp | 2 +- src/surf/surf_routing_full.cpp | 2 +- src/surf/surfxml_parse.c | 2 +- src/xbt/lib.c | 2 +- teshsuite/msg/storage/storage_basic.c | 2 +- 24 files changed, 36 insertions(+), 36 deletions(-) diff --git a/examples/msg/properties/msg_prop.c b/examples/msg/properties/msg_prop.c index e4bfca3db8..6ea54d82d1 100644 --- a/examples/msg/properties/msg_prop.c +++ b/examples/msg/properties/msg_prop.c @@ -62,7 +62,7 @@ static void test_host(const char*hostname) XBT_INFO(" Property: %s old value: %s", exist, value); XBT_INFO("== Trying to modify a host property"); - MSG_host_set_property_value(thehost, exist, xbt_strdup("250"), xbt_free); + MSG_host_set_property_value(thehost, exist, xbt_strdup("250"), xbt_free_f); /* Test if we have changed the value */ value = MSG_host_get_property_value(thehost, exist); @@ -73,7 +73,7 @@ static void test_host(const char*hostname) XBT_INFO(" Property: %s old value: %s", exist, value); /* Restore the value for the next test */ - MSG_host_set_property_value(thehost, exist, xbt_strdup("180"), xbt_free); + MSG_host_set_property_value(thehost, exist, xbt_strdup("180"), xbt_free_f); } int alice(int argc, char *argv[]) { /* Dump what we have on the current host */ diff --git a/examples/simdag/properties/sd_prop.c b/examples/simdag/properties/sd_prop.c index 1feae22c6d..0ffef3d412 100644 --- a/examples/simdag/properties/sd_prop.c +++ b/examples/simdag/properties/sd_prop.c @@ -54,7 +54,7 @@ int main(int argc, char **argv) /* Trying to set a new property */ - xbt_dict_set(props, "NewProp", strdup("newValue"), xbt_free); + xbt_dict_set(props, "NewProp", strdup("newValue"), xbt_free_f); /* Print the properties of the workstation 1 */ xbt_dict_foreach(props, cursor, key, data) { @@ -88,7 +88,7 @@ int main(int argc, char **argv) XBT_INFO("\tProperty: %s is undefined", exist); else { XBT_INFO("\tProperty: %s old value: %s", exist, value); - xbt_dict_set(props, exist, strdup("250"), xbt_free); + xbt_dict_set(props, exist, strdup("250"), xbt_free_f); } /* Test if we have changed the value */ diff --git a/include/smpi/smpi_cocci.h b/include/smpi/smpi_cocci.h index c4ea46fdbf..f938a9bdf2 100644 --- a/include/smpi/smpi_cocci.h +++ b/include/smpi/smpi_cocci.h @@ -56,7 +56,7 @@ XBT_PUBLIC(void) smpi_free_static(void); static type *name = NULL; \ if(!name) { \ name = (type*)calloc(smpi_global_size(), sizeof(type)); \ - smpi_register_static(name, xbt_free); \ + smpi_register_static(name, xbt_free_f); \ } #define SMPI_VARINIT_STATIC_AND_SET(name,type,expr) \ @@ -69,7 +69,7 @@ if(!name) { \ for(i = 0; i < size; i++) { \ name[i] = value; \ } \ - smpi_register_static(name, xbt_free); \ + smpi_register_static(name, xbt_free_f); \ } #define SMPI_VARGET_STATIC(name) name[smpi_process_index()] diff --git a/include/xbt/sysdep.h b/include/xbt/sysdep.h index 4b901a3592..4537717fb5 100644 --- a/include/xbt/sysdep.h +++ b/include/xbt/sysdep.h @@ -141,7 +141,7 @@ void *xbt_realloc(void *p, size_t s) /** @brief like free @hideinitializer */ -#define xbt_free free /*nothing specific to do here. A poor valgrind replacement? */ +#define xbt_free(p) free(p) /*nothing specific to do here. A poor valgrind replacement? */ /** @brief like free, but you can be sure that it is a function */ XBT_PUBLIC(void) xbt_free_f(void *p); diff --git a/src/bindings/java/jmsg_host.c b/src/bindings/java/jmsg_host.c index a7d54a38b0..9a75cfb987 100644 --- a/src/bindings/java/jmsg_host.c +++ b/src/bindings/java/jmsg_host.c @@ -245,7 +245,7 @@ Java_org_simgrid_msg_Host_setProperty(JNIEnv *env, jobject jhost, jobject jname, const char *value_java = (*env)->GetStringUTFChars(env, jvalue, 0); char *value = strdup(value_java); - MSG_host_set_property_value(host,name,value,xbt_free); + MSG_host_set_property_value(host, name, value, xbt_free_f); (*env)->ReleaseStringUTFChars(env, jvalue, value); (*env)->ReleaseStringUTFChars(env, jname, name); diff --git a/src/instr/instr_config.c b/src/instr/instr_config.c index ffc5da464f..091799b46c 100644 --- a/src/instr/instr_config.c +++ b/src/instr/instr_config.c @@ -133,11 +133,11 @@ int TRACE_start() XBT_DEBUG("Tracing is on"); /* other trace initialization */ - created_categories = xbt_dict_new_homogeneous(xbt_free); - declared_marks = xbt_dict_new_homogeneous(xbt_free); - user_host_variables = xbt_dict_new_homogeneous(xbt_free); - user_vm_variables = xbt_dict_new_homogeneous (xbt_free); - user_link_variables = xbt_dict_new_homogeneous(xbt_free); + created_categories = xbt_dict_new_homogeneous(xbt_free_f); + declared_marks = xbt_dict_new_homogeneous(xbt_free_f); + user_host_variables = xbt_dict_new_homogeneous(xbt_free_f); + user_vm_variables = xbt_dict_new_homogeneous(xbt_free_f); + user_link_variables = xbt_dict_new_homogeneous(xbt_free_f); if (TRACE_start_functions != NULL) { void (*func) (); diff --git a/src/instr/instr_interface.c b/src/instr/instr_interface.c index a8e97d3409..a2ff8b3fda 100644 --- a/src/instr/instr_interface.c +++ b/src/instr/instr_interface.c @@ -398,7 +398,7 @@ int TRACE_platform_graph_export_graphviz (const char *filename) xbt_graph_t g = instr_routing_platform_graph(); if (g == NULL) return 0; instr_routing_platform_graph_export_graphviz (g, filename); - xbt_graph_free_graph (g, xbt_free, xbt_free, NULL); + xbt_graph_free_graph(g, xbt_free_f, xbt_free_f, NULL); return 1; } diff --git a/src/instr/instr_paje_containers.c b/src/instr/instr_paje_containers.c index 0dc0d0a769..3a7ce52fc2 100644 --- a/src/instr/instr_paje_containers.c +++ b/src/instr/instr_paje_containers.c @@ -27,8 +27,8 @@ long long int instr_new_paje_id (void) void PJ_container_alloc (void) { allContainers = xbt_dict_new_homogeneous(NULL); - trivaNodeTypes = xbt_dict_new_homogeneous(xbt_free); - trivaEdgeTypes = xbt_dict_new_homogeneous(xbt_free); + trivaNodeTypes = xbt_dict_new_homogeneous(xbt_free_f); + trivaEdgeTypes = xbt_dict_new_homogeneous(xbt_free_f); } void PJ_container_release (void) diff --git a/src/instr/jedule/jedule_platform.c b/src/instr/jedule/jedule_platform.c index 370058c9cc..9a3fe8a03d 100644 --- a/src/instr/jedule/jedule_platform.c +++ b/src/instr/jedule/jedule_platform.c @@ -93,7 +93,7 @@ void jed_simgrid_add_resources(jed_simgrid_container_t parent, parent->is_lowest = 1; xbt_dynar_free(&parent->container_children); parent->container_children = NULL; - parent->name2id = xbt_dict_new_homogeneous(xbt_free); + parent->name2id = xbt_dict_new_homogeneous(xbt_free_f); parent->last_id = 0; parent->resource_list = xbt_dynar_new(sizeof(char *), NULL); diff --git a/src/smpi/instr_smpi.c b/src/smpi/instr_smpi.c index cd5a306fa5..d067768a2f 100644 --- a/src/smpi/instr_smpi.c +++ b/src/smpi/instr_smpi.c @@ -177,7 +177,7 @@ const char *TRACE_internal_smpi_get_category (void) void TRACE_smpi_alloc() { keys = xbt_dict_new_homogeneous(xbt_dynar_free_voidp); - process_category = xbt_dict_new_homogeneous(xbt_free); + process_category = xbt_dict_new_homogeneous(xbt_free_f); } void TRACE_smpi_release(void) diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index cc9e4097d8..9ac0887107 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -410,7 +410,7 @@ void smpi_mpi_start(MPI_Request request) simcall_comm_isend(mailbox, request->size, -1.0, buf, request->real_size, &match_send, - &xbt_free, // how to free the userdata if a detached send fails + &xbt_free_f, // how to free the userdata if a detached send fails &smpi_comm_copy_buffer_callback, request, // detach if msg size < eager/rdv switch limit diff --git a/src/smpi/smpi_bench.c b/src/smpi/smpi_bench.c index 8b37cab4ae..878f336b4e 100644 --- a/src/smpi/smpi_bench.c +++ b/src/smpi/smpi_bench.c @@ -118,7 +118,7 @@ static void* shm_map(int fd, size_t size, shared_data_t* data) { xbt_die("Could not map fd %d: %s", fd, strerror(errno)); } if(!allocs_metadata) { - allocs_metadata = xbt_dict_new_homogeneous(xbt_free); + allocs_metadata = xbt_dict_new_homogeneous(xbt_free_f); } snprintf(loc, PTR_STRLEN, "%p", mem); meta = xbt_new(shared_metadata_t, 1); diff --git a/src/smpi/smpi_deployment.c b/src/smpi/smpi_deployment.c index 55daf3bea6..33177ac333 100644 --- a/src/smpi/smpi_deployment.c +++ b/src/smpi/smpi_deployment.c @@ -49,7 +49,7 @@ void SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_ process_count+=num_processes; if(!smpi_instances){ - smpi_instances=xbt_dict_new_homogeneous(xbt_free); + smpi_instances = xbt_dict_new_homogeneous(xbt_free_f); } xbt_dict_set(smpi_instances, name, (void*)instance, NULL); diff --git a/src/surf/instr_routing.c b/src/surf/instr_routing.c index 0b0a772363..7dd95b1471 100644 --- a/src/surf/instr_routing.c +++ b/src/surf/instr_routing.c @@ -156,7 +156,7 @@ static void recursiveGraphExtraction (AS_t rc, container_t container, xbt_dict_t } xbt_dict_free (&nodes); xbt_dict_free (&edges); - xbt_graph_free_graph(graph,xbt_free, xbt_free, NULL); + xbt_graph_free_graph(graph, xbt_free_f, xbt_free_f, NULL); } } @@ -326,7 +326,7 @@ static void instr_routing_parse_end_platform () { xbt_dynar_free(¤tContainer); currentContainer = NULL; - xbt_dict_t filter = xbt_dict_new_homogeneous(xbt_free); + xbt_dict_t filter = xbt_dict_new_homogeneous(xbt_free_f); XBT_DEBUG ("Starting graph extraction."); recursiveGraphExtraction (surf_platf_get_root(routing_platf), PJ_container_get_root(), filter); XBT_DEBUG ("Graph extraction finished."); diff --git a/src/surf/platf_generator.c b/src/surf/platf_generator.c index feaf4ff09f..dab3cd50cb 100644 --- a/src/surf/platf_generator.c +++ b/src/surf/platf_generator.c @@ -447,7 +447,7 @@ void platf_graph_clear_links(void) { } //Delete edges from the graph xbt_dynar_foreach(dynar_edges_cpy, i, graph_edge) { - xbt_graph_free_edge(platform_graph, graph_edge, xbt_free); + xbt_graph_free_edge(platform_graph, graph_edge, xbt_free_f); } //remove the dynar copy xbt_dynar_free(&dynar_edges_cpy); diff --git a/src/surf/storage_interface.cpp b/src/surf/storage_interface.cpp index a068ac62e1..7d6a8b70a6 100644 --- a/src/surf/storage_interface.cpp +++ b/src/surf/storage_interface.cpp @@ -96,7 +96,7 @@ xbt_dict_t Storage::parseContent(char *filename) if ((!filename) || (strcmp(filename, "") == 0)) return NULL; - xbt_dict_t parse_content = xbt_dict_new_homogeneous(xbt_free); + xbt_dict_t parse_content = xbt_dict_new_homogeneous(xbt_free_f); FILE *file = NULL; file = surf_fopen(filename, "r"); diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 6cecbca440..04493201dd 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -195,7 +195,7 @@ static void storage_define_callbacks() void storage_register_callbacks() { - ROUTING_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,xbt_free); + ROUTING_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, xbt_free_f); ROUTING_STORAGE_HOST_LEVEL = xbt_lib_add_level(storage_lib, routing_storage_host_free); ROUTING_STORAGE_TYPE_LEVEL = xbt_lib_add_level(storage_type_lib, routing_storage_type_free); SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, surf_storage_resource_free); diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index 10584439b0..56d0f61589 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -634,7 +634,7 @@ xbt_dynar_t RoutingPlatf::getOneLinkRoutes(){ xbt_dynar_t RoutingPlatf::recursiveGetOneLinkRoutes(AsPtr rc) { - xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free); + xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free_f); //adding my one link routes xbt_dynar_t onelink_mine = rc->getOneLinkRoutes(); diff --git a/src/surf/surf_routing_dijkstra.cpp b/src/surf/surf_routing_dijkstra.cpp index 805dd10299..7c1ae30534 100644 --- a/src/surf/surf_routing_dijkstra.cpp +++ b/src/surf/surf_routing_dijkstra.cpp @@ -176,7 +176,7 @@ void AsDijkstra::addLoopback() { xbt_dynar_t AsDijkstra::getOnelinkRoutes() { - xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free); + xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free_f); sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1); route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t),NULL); @@ -278,7 +278,7 @@ void AsDijkstra::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_p int nr_nodes = xbt_dynar_length(nodes); cost_arr = xbt_new0(double, nr_nodes); /* link cost from src to other hosts */ pred_arr = xbt_new0(int, nr_nodes); /* predecessors in path from src */ - pqueue = xbt_heap_new(nr_nodes, xbt_free); + pqueue = xbt_heap_new(nr_nodes, xbt_free_f); /* initialize */ cost_arr[src_node_id] = 0.0; @@ -398,8 +398,8 @@ void AsDijkstra::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_p AsDijkstra::~AsDijkstra() { - xbt_graph_free_graph(p_routeGraph, &xbt_free, - &graph_edge_data_free, &xbt_free); + xbt_graph_free_graph(p_routeGraph, &xbt_free_f, + &graph_edge_data_free, &xbt_free_f); xbt_dict_free(&p_graphNodeMap); if (m_cached) xbt_dict_free(&p_routeCache); diff --git a/src/surf/surf_routing_floyd.cpp b/src/surf/surf_routing_floyd.cpp index 18d3c9ef66..7d4e9423f8 100644 --- a/src/surf/surf_routing_floyd.cpp +++ b/src/surf/surf_routing_floyd.cpp @@ -48,7 +48,7 @@ AsFloyd::~AsFloyd(){ /* Business methods */ xbt_dynar_t AsFloyd::getOneLinkRoutes() { - xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free); + xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free_f); sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1); route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); diff --git a/src/surf/surf_routing_full.cpp b/src/surf/surf_routing_full.cpp index d00fdb8f1f..4c74df4d96 100644 --- a/src/surf/surf_routing_full.cpp +++ b/src/surf/surf_routing_full.cpp @@ -71,7 +71,7 @@ AsFull::~AsFull(){ xbt_dynar_t AsFull::getOneLinkRoutes() { - xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free); + xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free_f); int src, dst; int table_size = xbt_dynar_length(p_indexNetworkElm); diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index ab38ab28ff..d19fdefba4 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -421,7 +421,7 @@ void STag_surfxml_prop(void) else{ if (!current_property_set) current_property_set = xbt_dict_new(); // Maybe, it should raise an error - xbt_dict_set(current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), xbt_free); + xbt_dict_set(current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), xbt_free_f); } } diff --git a/src/xbt/lib.c b/src/xbt/lib.c index 7fa4bc7caa..953666cddb 100644 --- a/src/xbt/lib.c +++ b/src/xbt/lib.c @@ -17,7 +17,7 @@ xbt_lib_t xbt_lib_new(void) { xbt_lib_t lib; lib = xbt_new(s_xbt_lib_t, 1); - lib->dict = xbt_dict_new_homogeneous(xbt_free); + lib->dict = xbt_dict_new_homogeneous(xbt_free_f); lib->levels = 0; lib->free_f = NULL; return lib; diff --git a/teshsuite/msg/storage/storage_basic.c b/teshsuite/msg/storage/storage_basic.c index b56ea02179..77577dc50b 100644 --- a/teshsuite/msg/storage/storage_basic.c +++ b/teshsuite/msg/storage/storage_basic.c @@ -146,7 +146,7 @@ void dump_platform_storages(void){ msg_storage_t storage; xbt_dynar_foreach(storages, cursor, storage){ XBT_INFO("Storage %s is attached to %s", MSG_storage_get_name(storage), MSG_storage_get_host(storage)); - MSG_storage_set_property_value(storage, "other usage", xbt_strdup("gpfs"), xbt_free); + MSG_storage_set_property_value(storage, "other usage", xbt_strdup("gpfs"), xbt_free_f); } xbt_dynar_free(&storages); } -- 2.20.1