Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make xbt_free a function-like macro.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Sat, 31 May 2014 21:08:11 +0000 (23:08 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Mon, 2 Jun 2014 12:25:16 +0000 (14:25 +0200)
Use xbt_free_f everywhere a pointer to function is needed.

24 files changed:
examples/msg/properties/msg_prop.c
examples/simdag/properties/sd_prop.c
include/smpi/smpi_cocci.h
include/xbt/sysdep.h
src/bindings/java/jmsg_host.c
src/instr/instr_config.c
src/instr/instr_interface.c
src/instr/instr_paje_containers.c
src/instr/jedule/jedule_platform.c
src/smpi/instr_smpi.c
src/smpi/smpi_base.c
src/smpi/smpi_bench.c
src/smpi/smpi_deployment.c
src/surf/instr_routing.c
src/surf/platf_generator.c
src/surf/storage_interface.cpp
src/surf/storage_n11.cpp
src/surf/surf_routing.cpp
src/surf/surf_routing_dijkstra.cpp
src/surf/surf_routing_floyd.cpp
src/surf/surf_routing_full.cpp
src/surf/surfxml_parse.c
src/xbt/lib.c
teshsuite/msg/storage/storage_basic.c

index e4bfca3..6ea54d8 100644 (file)
@@ -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 */
index 1feae22..0ffef3d 100644 (file)
@@ -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 */
index c4ea46f..f938a9b 100644 (file)
@@ -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()]
index 4b901a3..4537717 100644 (file)
@@ -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);
index a7d54a3..9a75cfb 100644 (file)
@@ -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);
index ffc5da4..091799b 100644 (file)
@@ -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) ();
index a8e97d3..a2ff8b3 100644 (file)
@@ -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;
 }
 
index 0dc0d0a..3a7ce52 100644 (file)
@@ -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)
index 370058c..9a3fe8a 100644 (file)
@@ -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);
 
index cd5a306..d067768 100644 (file)
@@ -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)
index cc9e409..9ac0887 100644 (file)
@@ -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
index 8b37cab..878f336 100644 (file)
@@ -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);
index 55daf3b..33177ac 100644 (file)
@@ -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);
index 0b0a772..7dd95b1 100644 (file)
@@ -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(&currentContainer);
   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.");
index feaf4ff..dab3cd5 100644 (file)
@@ -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);
index a068ac6..7d6a8b7 100644 (file)
@@ -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");
index 6cecbca..0449320 100644 (file)
@@ -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);
index 1058443..56d0f61 100644 (file)
@@ -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();
index 805dd10..7c1ae30 100644 (file)
@@ -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);
index 18d3c9e..7d4e942 100644 (file)
@@ -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);
 
index d00fdb8..4c74df4 100644 (file)
@@ -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);
index ab38ab2..d19fdef 100644 (file)
@@ -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);
   }
 }
 
index 7fa4bc7..953666c 100644 (file)
@@ -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;
index b56ea02..77577dc 100644 (file)
@@ -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);
 }