Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into MC_LTL
authorMarion Guthmuller <marion.guthmuller@loria.fr>
Wed, 30 Nov 2011 08:45:40 +0000 (09:45 +0100)
committerMarion Guthmuller <marion.guthmuller@loria.fr>
Wed, 30 Nov 2011 08:45:40 +0000 (09:45 +0100)
34 files changed:
ChangeLog
buildtools/Cmake/memcheck_tests.cmake
examples/msg/token_ring/token_ring.tesh
include/simix/context.h
include/xbt/config.h
include/xbt/dict.h
src/gras/Msg/msg_private.h
src/gras/Msg/rpc.c
src/instr/jedule/jedule_platform.c
src/instr/jedule/jedule_sd_binding.c
src/msg/msg_mailbox.c
src/msg/msg_private.h
src/simdag/private.h
src/simdag/sd_link.c
src/surf/cpu.c
src/surf/maxmin.c
src/surf/maxmin_private.h
src/surf/network_ns3.c
src/surf/surf_action.c
src/surf/surf_private.h
src/surf/surf_routing.c
src/surf/surf_routing_floyd.c
src/surf/workstation_ptask_L07.c
src/xbt/dict.c
src/xbt/dict_cursor.c
src/xbt/dict_elm.c
src/xbt/dict_private.h
src/xbt/dynar.c
src/xbt/fifo.c
src/xbt/log.c
src/xbt/mallocator.c
src/xbt/mallocator_private.h
src/xbt/set.c
tools/tesh/run_context.c

index b9cbe84..226f5c1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,9 @@ SimGrid (3.7) NOT RELEASED; urgency=low
     tasks that are finished and should constitute the return value of
     SD_simulate.
 
+  XBT:
+  * Mallocators: allow value NULL for the reset function.
+
   -- $date Da SimGrid team <simgrid-devel@lists.gforge.inria.fr>
 
 SimGrid (3.6.2) stable; urgency=low
index 01ed30e..0567077 100644 (file)
@@ -77,6 +77,7 @@ ADD_TEST(memcheck-tesh-simdag-parser-19 ${CMAKE_BINARY_DIR}/teshsuite/simdag/pla
 ADD_TEST(memcheck-tesh-simdag-parser-20 ${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms/basic_parsing_test ./properties.xml --cfg=cpu/model:CpuTI --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms/)
 ADD_TEST(memcheck-tesh-simdag-parser-21 ${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms/basic_parsing_test ./one_cluster_file.xml --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms/)
 ADD_TEST(memcheck-tesh-simdag-parser-22 ${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms/is_router_test ./test_of_is_router.xml --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms/)
+ADD_TEST(memcheck-tesh-simdag-parser-23 ${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms/basic_parsing_test ./Two_clusters_rulebased.xml ONE_LINK --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms/)
 ADD_TEST(memcheck-tesh-simdag-parser-sym-full-0 ${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms/basic_parsing_test one_cluster_fullduplex.xml FULL_LINK "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms/)
 ADD_TEST(memcheck-tesh-simdag-parser-sym-full-1 ${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms/basic_parsing_test two_clusters_symmetric.xml FULL_LINK "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms/)
 ADD_TEST(memcheck-tesh-simdag-parser-sym-full-2 ${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms/basic_parsing_test two_hosts_one_link_symmetrical.xml FULL_LINK "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms/)
@@ -166,17 +167,17 @@ ADD_TEST(memcheck-msg-masterslave-kill-raw-0 ${CMAKE_BINARY_DIR}/examples/msg/ma
 endif(HAVE_RAWCTX)
 
 ADD_TEST(memcheck-msg-masterslave-vivaldi-thread-0 ${CMAKE_BINARY_DIR}/examples/msg/masterslave/masterslave_mailbox  ${CMAKE_HOME_DIRECTORY}/examples/msg/../platforms/vivaldi.xml ${CMAKE_HOME_DIRECTORY}/examples/msg/masterslave/deployment_masterslave_vivaldi.xml --cfg=network/latency_factor:1.0 --cfg=network/bandwidth_factor:1.0 --cfg=contexts/factory:thread  --cd ${CMAKE_BINARY_DIR}/examples/msg/)
-ADD_TEST(memcheck-msg-token-ring-thread-0 token_ring ${CMAKE_HOME_DIRECTORY}/examples/msg/token_ring/two_clusters.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:thread  --cd ${CMAKE_BINARY_DIR}/examples/msg/token_ring/)
-ADD_TEST(memcheck-msg-token-ring-thread-1 token_ring ${CMAKE_HOME_DIRECTORY}/examples/msg/token_ring/two_peers.xml --cfg=coordinates:yes "--log=root.fmt:[%12.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:thread  --cd ${CMAKE_BINARY_DIR}/examples/msg/token_ring/)
+ADD_TEST(memcheck-msg-token-ring-thread-0 ${CMAKE_BINARY_DIR}/examples/msg/token_ring/token_ring ${CMAKE_HOME_DIRECTORY}/examples/msg/token_ring/two_clusters.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:thread  --cd ${CMAKE_BINARY_DIR}/examples/msg/token_ring/)
+ADD_TEST(memcheck-msg-token-ring-thread-1 ${CMAKE_BINARY_DIR}/examples/msg/token_ring/token_ring ${CMAKE_HOME_DIRECTORY}/examples/msg/token_ring/two_peers.xml --cfg=coordinates:yes "--log=root.fmt:[%12.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:thread  --cd ${CMAKE_BINARY_DIR}/examples/msg/token_ring/)
 if(HAVE_RAWCTX)
 ADD_TEST(memcheck-msg-masterslave-vivaldi-raw-0 ${CMAKE_BINARY_DIR}/examples/msg/masterslave/masterslave_mailbox  ${CMAKE_HOME_DIRECTORY}/examples/msg/../platforms/vivaldi.xml ${CMAKE_HOME_DIRECTORY}/examples/msg/masterslave/deployment_masterslave_vivaldi.xml --cfg=network/latency_factor:1.0 --cfg=network/bandwidth_factor:1.0 --cfg=contexts/factory:raw  --cd ${CMAKE_BINARY_DIR}/examples/msg/)
-ADD_TEST(memcheck-msg-token-ring-raw-0 token_ring ${CMAKE_HOME_DIRECTORY}/examples/msg/token_ring/two_clusters.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:raw  --cd ${CMAKE_BINARY_DIR}/examples/msg/token_ring/)
-ADD_TEST(memcheck-msg-token-ring-raw-1 token_ring ${CMAKE_HOME_DIRECTORY}/examples/msg/token_ring/two_peers.xml --cfg=coordinates:yes "--log=root.fmt:[%12.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:raw  --cd ${CMAKE_BINARY_DIR}/examples/msg/token_ring/)
+ADD_TEST(memcheck-msg-token-ring-raw-0 ${CMAKE_BINARY_DIR}/examples/msg/token_ring/token_ring ${CMAKE_HOME_DIRECTORY}/examples/msg/token_ring/two_clusters.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:raw  --cd ${CMAKE_BINARY_DIR}/examples/msg/token_ring/)
+ADD_TEST(memcheck-msg-token-ring-raw-1 ${CMAKE_BINARY_DIR}/examples/msg/token_ring/token_ring ${CMAKE_HOME_DIRECTORY}/examples/msg/token_ring/two_peers.xml --cfg=coordinates:yes "--log=root.fmt:[%12.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:raw  --cd ${CMAKE_BINARY_DIR}/examples/msg/token_ring/)
 endif(HAVE_RAWCTX)
 if(HAVE_UCONTEXT_H)
 ADD_TEST(memcheck-msg-masterslave-vivaldi-ucontext-0 ${CMAKE_BINARY_DIR}/examples/msg/masterslave/masterslave_mailbox  ${CMAKE_HOME_DIRECTORY}/examples/msg/../platforms/vivaldi.xml ${CMAKE_HOME_DIRECTORY}/examples/msg/masterslave/deployment_masterslave_vivaldi.xml --cfg=network/latency_factor:1.0 --cfg=network/bandwidth_factor:1.0 --cfg=contexts/factory:ucontext  --cd ${CMAKE_BINARY_DIR}/examples/msg/)
-ADD_TEST(memcheck-msg-token-ring-ucontext-0 token_ring ${CMAKE_HOME_DIRECTORY}/examples/msg/token_ring/two_clusters.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:ucontext  --cd ${CMAKE_BINARY_DIR}/examples/msg/token_ring/)
-ADD_TEST(memcheck-msg-token-ring-ucontext-1 token_ring ${CMAKE_HOME_DIRECTORY}/examples/msg/token_ring/two_peers.xml --cfg=coordinates:yes "--log=root.fmt:[%12.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:ucontext  --cd ${CMAKE_BINARY_DIR}/examples/msg/token_ring/)
+ADD_TEST(memcheck-msg-token-ring-ucontext-0 ${CMAKE_BINARY_DIR}/examples/msg/token_ring/token_ring ${CMAKE_HOME_DIRECTORY}/examples/msg/token_ring/two_clusters.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:ucontext  --cd ${CMAKE_BINARY_DIR}/examples/msg/token_ring/)
+ADD_TEST(memcheck-msg-token-ring-ucontext-1 ${CMAKE_BINARY_DIR}/examples/msg/token_ring/token_ring ${CMAKE_HOME_DIRECTORY}/examples/msg/token_ring/two_peers.xml --cfg=coordinates:yes "--log=root.fmt:[%12.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:ucontext  --cd ${CMAKE_BINARY_DIR}/examples/msg/token_ring/)
 endif(HAVE_UCONTEXT_H)
 
 ADD_TEST(memcheck-msg-masterslave-multicore-thread-0 ${CMAKE_BINARY_DIR}/examples/msg/masterslave/masterslave_mailbox ${CMAKE_HOME_DIRECTORY}/examples/msg/../platforms/multicore_machine.xml ${CMAKE_HOME_DIRECTORY}/examples/msg/masterslave/deployment_masterslave_mailbox_multicore.xml --cfg=cpu/model:Cas01_fullupdate --cfg=contexts/factory:thread  --cd ${CMAKE_BINARY_DIR}/examples/msg/)
index 8263239..02147a9 100644 (file)
@@ -1,7 +1,7 @@
 #! ./tesh
 
 ! output sort
-$ $SG_TEST_EXENV token_ring ${srcdir:=.}/two_clusters.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ $SG_TEST_EXENV ${bindir:=.}/token_ring ${srcdir:=.}/two_clusters.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (0:@) Bypassing the XML parser since surf_parse_open received a NULL pointer. If it is not what you want, go fix your code.
 > [  0.066240] (1:master@bob1.hamburger.edu) Send Data to "host1"
 > [  0.066240] (2:slave@bob3.hamburger.edu) Received "Token"
@@ -26,7 +26,7 @@ $ $SG_TEST_EXENV token_ring ${srcdir:=.}/two_clusters.xml "--log=root.fmt:[%10.6
 > [  1.104000] (1:master@bob1.hamburger.edu) Received "Token"
 
 ! output sort
-$ $SG_TEST_EXENV token_ring ${srcdir:=.}/two_peers.xml --cfg=coordinates:yes "--log=root.fmt:[%12.6r]%e(%i:%P@%h)%e%m%n"
+$ $SG_TEST_EXENV ${bindir:=.}/token_ring ${srcdir:=.}/two_peers.xml --cfg=coordinates:yes "--log=root.fmt:[%12.6r]%e(%i:%P@%h)%e%m%n"
 > [    0.000000] (0:@) Configuration change: Set 'coordinates' to 'yes'
 > [    0.000000] (0:@) Bypassing the XML parser since surf_parse_open received a NULL pointer. If it is not what you want, go fix your code.
 > [    5.221778] (1:master@peer_100030591) Send Data to "host1"
index 4b4d5b9..71d1e6d 100644 (file)
@@ -74,11 +74,11 @@ extern smx_context_t smx_current_context;
 typedef struct s_smx_context {
   s_xbt_swag_hookup_t hookup;
   xbt_main_func_t code;
-  int argc;
-  char **argv;
   void_pfn_smxprocess_t cleanup_func;
-  int iwannadie:1;
   void *data;   /* Here SIMIX stores the smx_process_t containing the context */
+  char **argv;
+  int argc;
+  int iwannadie:1;
 } s_smx_ctx_base_t;
 
 /* methods of this class */
index a352595..0ddcff7 100644 (file)
@@ -88,8 +88,8 @@ SG_BEGIN_DECL()
  *
  * @{
  */
-  /** @brief Configuration set are only special dynars. But don't rely on it, it may change. */
-typedef xbt_dynar_t xbt_cfg_t;
+/** @brief Configuration set's data type is opaque. */
+typedef void* xbt_cfg_t;
 
 XBT_PUBLIC(void) xbt_cfg_set(xbt_cfg_t cfg, const char *name, ...);
 XBT_PUBLIC(void) xbt_cfg_set_vargs(xbt_cfg_t cfg, const char *name,
index f5256cf..cb5cde6 100644 (file)
@@ -43,7 +43,7 @@ SG_BEGIN_DECL()
  */
 
   /** \brief Dictionary data type (opaque structure) */
-typedef struct xbt_dict_ *xbt_dict_t;
+typedef struct s_xbt_dict *xbt_dict_t;
 XBT_PUBLIC(xbt_dict_t) xbt_dict_new(void);
 XBT_PUBLIC(void) xbt_dict_free(xbt_dict_t * dict);
 XBT_PUBLIC(unsigned int) xbt_dict_size(xbt_dict_t dict);
@@ -120,7 +120,7 @@ XBT_PUBLIC(void) xbt_dicti_remove(xbt_dict_t dict, uintptr_t key);
  *  @{ */
 
   /** @brief Cursor on dictionaries (opaque type) */
-typedef struct xbt_dict_cursor_ *xbt_dict_cursor_t;
+typedef struct s_xbt_dict_cursor *xbt_dict_cursor_t;
 XBT_PUBLIC(xbt_dict_cursor_t) xbt_dict_cursor_new(const xbt_dict_t dict);
 XBT_PUBLIC(void) xbt_dict_cursor_free(xbt_dict_cursor_t * cursor);
 
index b760e08..a124213 100644 (file)
@@ -130,7 +130,7 @@ gras_msg_cb_ctx_t gras_msg_cb_ctx_new(gras_socket_t expe,
 #include "xbt/mallocator.h"
 extern xbt_mallocator_t gras_msg_ctx_mallocator;
 void *gras_msg_ctx_mallocator_new_f(void);
-void gras_msg_ctx_mallocator_free_f(void *dict);
+#define gras_msg_ctx_mallocator_free_f xbt_free_f
 void gras_msg_ctx_mallocator_reset_f(void *dict);
 
 
index 8c7e72c..c84c605 100644 (file)
@@ -104,11 +104,6 @@ void *gras_msg_ctx_mallocator_new_f(void)
   return xbt_new0(s_gras_msg_cb_ctx_t, 1);
 }
 
-void gras_msg_ctx_mallocator_free_f(void *ctx)
-{
-  xbt_free(ctx);
-}
-
 void gras_msg_ctx_mallocator_reset_f(void *ctx)
 {
   memset(ctx, 0, sizeof(s_gras_msg_cb_ctx_t));
index ebcfa4b..d6b488b 100644 (file)
@@ -86,8 +86,7 @@ void jed_simgrid_add_resources(jed_simgrid_container_t parent,
 
        unsigned int iter;
        char *host_name;
-       char buf[16];
-       char *buf_copy;
+       char *buf;
 
        parent->is_lowest = 1;
        xbt_dynar_free(&parent->container_children);
@@ -99,10 +98,9 @@ void jed_simgrid_add_resources(jed_simgrid_container_t parent,
        xbt_dynar_sort (host_names,     &compare_hostnames);
 
        xbt_dynar_foreach(host_names, iter, host_name) {
-               buf_copy = strdup(buf);
-               sprintf(buf_copy, "%d", parent->last_id);
+               buf = bprintf("%d", parent->last_id);
                (parent->last_id)++;
-               xbt_dict_set(parent->name2id, host_name, buf_copy, NULL);
+               xbt_dict_set(parent->name2id, host_name, buf, xbt_free);
                xbt_dict_set(host2_simgrid_parent_container, host_name, parent, NULL);
                xbt_dynar_push(parent->resource_list, &host_name);
        }
index 9ecf7cb..67a1e91 100644 (file)
@@ -12,6 +12,7 @@
 #include "xbt/dynar.h"
 
 #include "surf/surf_private.h"
+#include "surf/surf_resource.h"
 #include "surf/surf.h"
 
 #include "instr/jedule/jedule_sd_binding.h"
index 0990c45..e25051c 100644 (file)
@@ -79,7 +79,7 @@ MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t * task,
   CHECK_HOST();
 #ifdef HAVE_TRACING
   TRACE_msg_task_get_start();
-  double start_time = MSG_get_clock();
+  volatile double start_time = MSG_get_clock();
 #endif
 
   /* Sanity check */
index cf9f975..e8af564 100644 (file)
@@ -55,8 +55,8 @@ typedef struct simdata_process {
   m_channel_t put_channel;      /* used for debugging purposes */
   smx_action_t waiting_action;
   m_task_t waiting_task;
-  int argc;                     /* arguments number if any */
   char **argv;                  /* arguments table if any */
+  int argc;                     /* arguments number if any */
   MSG_error_t last_errno;       /* the last value returned by a MSG_function */
   void* data;                   /* user data */
 } s_simdata_process_t, *simdata_process_t;
index 7b55cfa..61ba759 100644 (file)
@@ -117,7 +117,7 @@ XBT_PUBLIC(xbt_swag_t) SD_simulate_swag(double how_long); /* could be public, bu
 
 
 SD_link_t __SD_link_create(void *surf_link, void *data);
-void __SD_link_destroy(void *link);
+#define __SD_link_destroy xbt_free_f
 
 SD_workstation_t __SD_workstation_create(void *surf_workstation,
                                          void *data);
index 2cf0faa..b9b83bb 100644 (file)
@@ -146,12 +146,3 @@ e_SD_link_sharing_policy_t SD_link_get_sharing_policy(SD_link_t link)
 {
   return link->sharing_policy;
 }
-
-
-/* Destroys a link.
- */
-void __SD_link_destroy(void *link)
-{
-  /* link->surf_link is freed by surf_exit and link->data is freed by the user */
-  xbt_free(link);
-}
index b0d69b5..443ae7e 100644 (file)
@@ -15,8 +15,8 @@ typedef struct cpu_Cas01 {
   s_surf_resource_t generic_resource;
   double power_peak;
   double power_scale;
-  int core;
   tmgr_trace_event_t power_event;
+  int core;
   e_surf_resource_state_t state_current;
   tmgr_trace_event_t state_event;
   lmm_constraint_t constraint;
index dc331ad..b75e448 100644 (file)
@@ -19,7 +19,7 @@ double sg_maxmin_precision = 0.00001;
 
 static void *lmm_variable_mallocator_new_f(void);
 static void lmm_variable_mallocator_free_f(void *var);
-static void lmm_variable_mallocator_reset_f(void *var);
+#define lmm_variable_mallocator_reset_f ((void_f_pvoid_t)NULL)
 static void lmm_update_modified_set(lmm_system_t sys,
                                     lmm_constraint_t cnst);
 static void lmm_remove_all_modified_set(lmm_system_t sys);
@@ -173,11 +173,6 @@ static void lmm_variable_mallocator_free_f(void *var)
   xbt_free(var);
 }
 
-static void lmm_variable_mallocator_reset_f(void *var)
-{
-  /* lmm_variable_new() initializes everything */
-}
-
 lmm_variable_t lmm_variable_new(lmm_system_t sys, void *id,
                                 double weight,
                                 double bound, int number_of_constraints)
index e4fe040..21370d7 100644 (file)
@@ -36,10 +36,10 @@ typedef struct lmm_constraint {
   double lambda;
   double new_lambda;
   double remaining;
-  int shared;
   double usage;
   void *id;
   int id_int;
+  int shared;
 } s_lmm_constraint_t;
 
 typedef struct lmm_variable {
index f8d5841..7b4a54f 100644 (file)
@@ -323,10 +323,6 @@ static void define_callbacks_ns3(void)
   surfxml_add_callback(ETag_surfxml_platform_cb_list, &parse_ns3_end_platform); //InitializeRoutes
 }
 
-static void free_ns3_elmts(void * elmts)
-{
-}
-
 static void free_ns3_link(void * elmts)
 {
        ns3_link_t link = elmts;
index ea4317b..49a22ff 100644 (file)
@@ -27,7 +27,7 @@ const char *surf_action_state_names[6] = {
 static xbt_mallocator_t action_mallocator = NULL;
 static int action_mallocator_allocated_size = 0;
 static void* surf_action_mallocator_new_f(void);
-static void surf_action_mallocator_free_f(void* action);
+#define surf_action_mallocator_free_f xbt_free_f
 static void surf_action_mallocator_reset_f(void* action);
 
 /**
@@ -55,10 +55,6 @@ static void* surf_action_mallocator_new_f(void) {
   return xbt_malloc(action_mallocator_allocated_size);
 }
 
-static void surf_action_mallocator_free_f(void* action) {
-  xbt_free(action);
-}
-
 static void surf_action_mallocator_reset_f(void* action) {
   memset(action, 0, action_mallocator_allocated_size);
 }
index d8a993c..17bd311 100644 (file)
@@ -164,6 +164,7 @@ struct s_routing_global {
   AS_t root;
   void *loopback;
   size_t size_of_link;
+  xbt_dynar_t last_route;
   xbt_dynar_t(*get_onelink_routes) (void);
 };
 
index 354272f..38e071a 100644 (file)
@@ -588,13 +588,9 @@ static void _get_route_and_latency(const char *src, const char *dst,
 void routing_get_route_and_latency(const char *src, const char *dst,
                                    xbt_dynar_t * route, double *latency)
 {
-  static xbt_dynar_t last_route = NULL;
-
-  int need_cleanup = !(*route);
-
-  if (need_cleanup) {
-    xbt_dynar_free(&last_route);
-    last_route = *route = xbt_dynar_new(global_routing->size_of_link,NULL);
+  if (!*route) {
+    xbt_dynar_reset(global_routing->last_route);
+    *route = global_routing->last_route;
   }
 
   _get_route_and_latency(src, dst, route, latency);
@@ -664,6 +660,7 @@ void routing_model_create(size_t size_of_links, void *loopback)
   global_routing->get_onelink_routes = get_onelink_routes;
   global_routing->loopback = loopback;
   global_routing->size_of_link = size_of_links;
+  global_routing->last_route = xbt_dynar_new(global_routing->size_of_link,NULL);
   /* no current routing at moment */
   current_routing = NULL;
 }
@@ -1147,6 +1144,7 @@ static void finalize_rec(AS_t as) {
 void routing_exit(void) {
   if (!global_routing)
     return;
+  xbt_dynar_free(&global_routing->last_route);
   finalize_rec(global_routing->root);
   xbt_free(global_routing);
 }
index e094d6c..ea030ea 100644 (file)
@@ -104,7 +104,8 @@ static void floyd_get_route_and_latency(AS_t asg, const char *src, const char *d
 
     if (asg->hierarchy == SURF_ROUTING_RECURSIVE && !first
         && strcmp(gw_dst, prev_gw_src)) {
-      xbt_dynar_t e_route_as_to_as=NULL;
+      xbt_dynar_t e_route_as_to_as;
+      e_route_as_to_as = xbt_dynar_new(global_routing->size_of_link, NULL);
       routing_get_route_and_latency(gw_dst, prev_gw_src,&e_route_as_to_as,NULL);
       links = e_route_as_to_as;
       int pos = 0;
@@ -114,6 +115,7 @@ static void floyd_get_route_and_latency(AS_t asg, const char *src, const char *d
           *lat += surf_network_model->extension.network.get_link_latency(link);
         pos++;
       }
+      xbt_dynar_free(&e_route_as_to_as);
     }
 
     links = e_route->link_list;
@@ -150,8 +152,9 @@ static void floyd_finalize(AS_t rc)
     xbt_dict_free(&as->generic_routing.bypassRoutes);
     /* Delete index dict */
     xbt_dict_free(&(as->generic_routing.to_index));
-    /* Delete dictionary index dict, predecessor and links table */
+    /* Delete predecessor and cost table */
     xbt_free(as->predecessor_table);
+    xbt_free(as->cost_table);
 
     model_generic_finalize(rc);
   }
@@ -340,8 +343,8 @@ void model_floyd_parse_route(AS_t rc, const char *src,
                {
                        if(route->dst_gateway && route->src_gateway)
                        {
-                          char *gw_src = xbt_strdup(route->src_gateway);
-                          char *gw_dst = xbt_strdup(route->dst_gateway);
+                          char *gw_src = route->src_gateway;
+                          char *gw_dst = route->dst_gateway;
                           route->src_gateway = gw_dst;
                           route->dst_gateway = gw_src;
                        }
index ce71a99..b8ecc23 100644 (file)
@@ -26,8 +26,8 @@ typedef struct cpu_L07 {
   double power_scale;
   double power_current;
   tmgr_trace_event_t power_event;
-  e_surf_resource_state_t state_current;
   tmgr_trace_event_t state_event;
+  e_surf_resource_state_t state_current;
   int id;                       /* cpu and network card are a single object... */
 } s_cpu_L07_t, *cpu_L07_t;
 
@@ -729,7 +729,7 @@ static void ptask_parse_link_init(sg_platf_link_cbarg_t link)
                                link->properties);
     xbt_free(link_id);
     link_id = bprintf("%s_DOWN", link->id);
-    ptask_link_create_resource(bprintf("%s_DOWN", link->id),
+    ptask_link_create_resource(link_id,
                                link->bandwidth,
                                link->bandwidth_trace,
                                link->latency,
index c58f0c0..b0a5031 100644 (file)
@@ -23,8 +23,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_dict, xbt,
 
 static xbt_mallocator_t dict_mallocator = NULL;
 static void *dict_mallocator_new_f(void);
-static void dict_mallocator_free_f(void *dict);
-static void dict_mallocator_reset_f(void *dict);
+#define dict_mallocator_free_f xbt_free_f
+#define dict_mallocator_reset_f ((void_f_pvoid_t)NULL)
 
 
 /*####[ Code ]###############################################################*/
@@ -32,7 +32,7 @@ static void dict_mallocator_reset_f(void *dict);
 /**
  * \brief Constructor
  * \return pointer to the destination
- * \see xbt_dict_new_ext(), xbt_dict_free()
+ * \see xbt_dict_free()
  *
  * Creates and initialize a new dictionary with a default hashtable size.
  */
@@ -816,18 +816,6 @@ static void *dict_mallocator_new_f(void)
   return xbt_new(s_xbt_dict_t, 1);
 }
 
-static void dict_mallocator_free_f(void *dict)
-{
-  xbt_free(dict);
-}
-
-static void dict_mallocator_reset_f(void *dict)
-{
-  /* nothing to do because all fields are
-   * initialized in xbt_dict_new
-   */
-}
-
 #ifdef SIMGRID_TEST
 #include "xbt.h"
 #include "xbt/ex.h"
index 6d7f277..8d78868 100644 (file)
@@ -21,7 +21,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_dict_cursor, xbt_dict,
 /* To traverse (simple) dicts                                               */
 /* Don't add or remove entries to the dict while traversing !!!             */
 /*###########################################################################*/
-struct xbt_dict_cursor_ {
+struct s_xbt_dict_cursor {
   xbt_dictelm_t current;
   int line;
   xbt_dict_t dict;
index 4129989..0591621 100644 (file)
@@ -81,13 +81,3 @@ void *dict_elm_mallocator_new_f(void)
 {
   return xbt_new(s_xbt_dictelm_t, 1);
 }
-
-void dict_elm_mallocator_free_f(void *elem)
-{
-  xbt_free(elem);
-}
-
-void dict_elm_mallocator_reset_f(void *elem)
-{
-
-}
index c1b6402..033500f 100644 (file)
 #include "xbt/dict.h"
 #include "xbt/mallocator.h"
 
-typedef struct xbt_dictelm_ *xbt_dictelm_t;
+typedef struct s_xbt_dictelm *xbt_dictelm_t;
 
 #define MAX_FILL_PERCENT 80
 
-typedef struct xbt_dictelm_ {
+typedef struct s_xbt_dictelm {
   int dictielem:1;
   char *key;
   int key_len;
@@ -33,19 +33,19 @@ typedef struct xbt_dictelm_ {
   xbt_dictelm_t next;
 } s_xbt_dictelm_t;
 
-typedef struct xbt_dict_ {
+typedef struct s_xbt_dict {
   xbt_dictelm_t *table;
   int table_size;
   int count;
   int fill;
 } s_xbt_dict_t;
 
-typedef struct xbt_dict_cursor_ s_xbt_dict_cursor_t;
+typedef struct s_xbt_dict_cursor s_xbt_dict_cursor_t;
 
 extern xbt_mallocator_t dict_elm_mallocator;
 extern void *dict_elm_mallocator_new_f(void);
-extern void dict_elm_mallocator_free_f(void *elem);
-extern void dict_elm_mallocator_reset_f(void *elem);
+#define dict_elm_mallocator_free_f xbt_free_f
+#define dict_elm_mallocator_reset_f ((void_f_pvoid_t)NULL)
 
 /*####[ Function prototypes ]################################################*/
 xbt_dictelm_t xbt_dictelm_new(const char *key, int key_len,
@@ -54,6 +54,5 @@ xbt_dictelm_t xbt_dictelm_new(const char *key, int key_len,
 xbt_dictelm_t xbt_dictielm_new(uintptr_t key, unsigned int hash_code,
                                uintptr_t content);
 void xbt_dictelm_free(xbt_dictelm_t element);
-void xbt_dict_add_element(xbt_dict_t dict, xbt_dictelm_t element);
 
 #endif                          /* _XBT_DICT_PRIVATE_H_ */
index 657e8f2..c630ff0 100644 (file)
@@ -6,7 +6,6 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "portable.h"           /* SIZEOF_MAX */
 #include "xbt/misc.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
@@ -75,9 +74,12 @@ static XBT_INLINE void _check_populated_dynar(xbt_dynar_t dynar)
 static void _dynar_map(const xbt_dynar_t dynar, void_f_pvoid_t const op);
 
 static XBT_INLINE
-    void _xbt_clear_mem(void *const ptr, const unsigned long length)
+void _xbt_dynar_resize(xbt_dynar_t dynar, unsigned long new_size)
 {
-  memset(ptr, 0, length);
+  if (new_size != dynar->size) {
+    dynar->size = new_size;
+    dynar->data = xbt_realloc(dynar->data, new_size * dynar->elmsize);
+  }
 }
 
 static XBT_INLINE
@@ -86,21 +88,10 @@ static XBT_INLINE
   const unsigned long old_size = dynar->size;
 
   if (nb > old_size) {
-    void *const old_data = dynar->data;
-    const unsigned long elmsize = dynar->elmsize;
-    const unsigned long old_length = old_size * elmsize;
-
     const unsigned long expand = 2 * (old_size + 1);
-    const unsigned long new_size = (nb > expand ? nb : expand);
-    const unsigned long new_length = new_size * elmsize;
-    void *const new_data = xbt_realloc(old_data, new_length);
-
-    XBT_DEBUG("expand %p from %lu to %lu elements", dynar, old_size, new_size);
-
-    _xbt_clear_mem((char *)new_data + old_length, new_length - old_length);
-
-    dynar->size = new_size;
-    dynar->data = new_data;
+    _xbt_dynar_resize(dynar, (nb > expand ? nb : expand));
+    XBT_DEBUG("expand %p from %lu to %lu elements",
+              dynar, old_size, dynar->size);
   }
 }
 
@@ -149,16 +140,7 @@ _xbt_dynar_remove_at(xbt_dynar_t const dynar,
   if (object) {
     _xbt_dynar_get_elm(object, dynar, idx);
   } else if (dynar->free_f) {
-    if (dynar->elmsize <= SIZEOF_MAX) {
-      char elm[SIZEOF_MAX];
-      _xbt_dynar_get_elm(elm, dynar, idx);
-      dynar->free_f(elm);
-    } else {
-      char *elm = malloc(dynar->elmsize);
-      _xbt_dynar_get_elm(elm, dynar, idx);
-      dynar->free_f(elm);
-      free(elm);
-    }
+    dynar->free_f(_xbt_dynar_elm(dynar, idx));
   }
 
   nb_shift = dynar->used - 1 - idx;
@@ -228,18 +210,11 @@ xbt_dynar_new_sync(const unsigned long elmsize,
 void xbt_dynar_free_container(xbt_dynar_t * dynar)
 {
   if (dynar && *dynar) {
-
-    if ((*dynar)->data) {
-      _xbt_clear_mem((*dynar)->data, (*dynar)->size);
-      free((*dynar)->data);
-    }
-
-    if ((*dynar)->mutex)
-      xbt_mutex_destroy((*dynar)->mutex);
-
-    _xbt_clear_mem(*dynar, sizeof(s_xbt_dynar_t));
-
-    free(*dynar);
+    xbt_dynar_t d = *dynar;
+    free(d->data);
+    if (d->mutex)
+      xbt_mutex_destroy(d->mutex);
+    free(d);
     *dynar = NULL;
   }
 }
@@ -258,16 +233,9 @@ XBT_INLINE void xbt_dynar_reset(xbt_dynar_t const dynar)
   if (dynar->free_f) {
     _dynar_map(dynar, dynar->free_f);
   }
-  /*
-     free(dynar->data);
-
-     dynar->size = 0;
-   */
   dynar->used = 0;
 
   _dynar_unlock(dynar);
-
-  /*  dynar->data = NULL; */
 }
 
 /**
@@ -287,15 +255,8 @@ XBT_INLINE void xbt_dynar_reset(xbt_dynar_t const dynar)
  */
 void xbt_dynar_shrink(xbt_dynar_t dynar, int empty_slots_wanted)
 {
-  unsigned long size_wanted;
-
   _dynar_lock(dynar);
-
-  size_wanted = dynar->used + empty_slots_wanted;
-  if (size_wanted != dynar->size) {
-    dynar->size = size_wanted;
-    dynar->data = xbt_realloc(dynar->data, dynar->elmsize * dynar->size);
-  }
+  _xbt_dynar_resize(dynar, dynar->used + empty_slots_wanted);
   _dynar_unlock(dynar);
 }
 
@@ -381,26 +342,30 @@ XBT_INLINE void *xbt_dynar_get_ptr(const xbt_dynar_t dynar,
   return res;
 }
 
-XBT_INLINE void *xbt_dynar_set_at_ptr(const xbt_dynar_t dynar,
-                                      const unsigned long idx)
+/* not synchronized */
+static XBT_INLINE void *_xbt_dynar_set_at_ptr(const xbt_dynar_t dynar,
+                                              const unsigned long idx)
 {
-
-  void *res;
-  _dynar_lock(dynar);
   _sanity_check_dynar(dynar);
 
-  _xbt_dynar_expand(dynar, idx + 1);
-
   if (idx >= dynar->used) {
-    _xbt_clear_mem(((char * const)dynar->data) + dynar->used * dynar->elmsize,
-                   (idx + 1 - dynar->used)*dynar->elmsize);
+    _xbt_dynar_expand(dynar, idx + 1);
+    if (idx > dynar->used) {
+      memset(_xbt_dynar_elm(dynar, dynar->used), 0,
+             (idx - dynar->used) * dynar->elmsize);
+    }
     dynar->used = idx + 1;
   }
-  
-  _dynar_unlock(dynar);
-
-  res = _xbt_dynar_elm(dynar, idx);
+  return _xbt_dynar_elm(dynar, idx);
+}
 
+XBT_INLINE void *xbt_dynar_set_at_ptr(const xbt_dynar_t dynar,
+                                      const unsigned long idx)
+{
+  void *res;
+  _dynar_lock(dynar);
+  res = _xbt_dynar_set_at_ptr(dynar, idx);
+  _dynar_unlock(dynar);
   return res;
 }
 
@@ -408,18 +373,7 @@ static void XBT_INLINE          /* not synchronized */
 _xbt_dynar_set(xbt_dynar_t dynar,
                const unsigned long idx, const void *const src)
 {
-
-  _sanity_check_dynar(dynar);
-
-  _xbt_dynar_expand(dynar, idx + 1);
-
-  if (idx >= dynar->used) {
-    _xbt_clear_mem(((char * const)dynar->data) + dynar->used * dynar->elmsize,
-                   (idx + 1 - dynar->used)*dynar->elmsize);
-    dynar->used = idx + 1;
-  }
-
-  _xbt_dynar_put_elm(dynar, idx, src);
+  memcpy(_xbt_dynar_set_at_ptr(dynar, idx), src, dynar->elmsize);
 }
 
 /** @brief Set the Nth element of a dynar (expanded if needed). Previous value at this position is NOT freed
@@ -750,13 +704,14 @@ XBT_INLINE void xbt_dynar_sort(xbt_dynar_t dynar,
  */
 XBT_INLINE void * xbt_dynar_to_array (xbt_dynar_t dynar)
 {
-  void * res;
-       void * last = xbt_new0(char,dynar->elmsize);
-       xbt_dynar_push(dynar, last);
-       free(last);
-       res = dynar->data;
-       free(dynar);
-       return res;
+  void *res;
+  xbt_dynar_shrink(dynar, 1);
+  memset(xbt_dynar_push_ptr(dynar), 0, dynar->elmsize);
+  res = dynar->data;
+  if (dynar->mutex)
+    xbt_mutex_destroy(dynar->mutex);
+  free(dynar);
+  return res;
 }
 
 /*
index 89ab25f..57e0912 100644 (file)
@@ -13,7 +13,7 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_fifo, xbt, "FIFO");
 
 static void *fifo_item_mallocator_new_f(void);
-static void fifo_item_mallocator_free_f(void *item);
+#define fifo_item_mallocator_free_f xbt_free_f
 static void fifo_item_mallocator_reset_f(void *item);
 
 static xbt_mallocator_t item_mallocator = NULL;
@@ -375,11 +375,6 @@ static void *fifo_item_mallocator_new_f(void)
   return xbt_new(s_xbt_fifo_item_t, 1);
 }
 
-static void fifo_item_mallocator_free_f(void *item)
-{
-  xbt_free(item);
-}
-
 static void fifo_item_mallocator_reset_f(void *item)
 {
   /* memset to zero like calloc */
index d772211..4bed85f 100644 (file)
@@ -473,8 +473,8 @@ xbt_log_layout_t xbt_log_default_layout = NULL; /* set in log_init */
 
 typedef struct {
   char *catname;
-  e_xbt_log_priority_t thresh;
   char *fmt;
+  e_xbt_log_priority_t thresh;
   int additivity;
   xbt_log_appender_t appender;
 } s_xbt_log_setting_t, *xbt_log_setting_t;
index b8427aa..ed415a5 100644 (file)
@@ -35,7 +35,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_mallocator, xbt, "Mallocators");
  * in \a xbt_mallocator_release() when the stack is full, and when
  * the mallocator is freed.
  * \param reset_f function to reinitialise an object of your datatype, called
- * when you extract an object from the mallocator
+ * when you extract an object from the mallocator (can be NULL)
  *
  * Create and initialize a new mallocator for a given datatype.
  *
@@ -50,8 +50,7 @@ xbt_mallocator_t xbt_mallocator_new(int size,
   xbt_mallocator_t m;
 
   xbt_assert(size > 0, "size must be positive");
-  xbt_assert(new_f != NULL && free_f != NULL
-              && reset_f != NULL, "invalid parameter");
+  xbt_assert(new_f != NULL && free_f != NULL, "invalid parameter");
 
   m = xbt_new0(s_xbt_mallocator_t, 1);
   XBT_VERB("Create mallocator %p", m);
@@ -108,7 +107,7 @@ void xbt_mallocator_free(xbt_mallocator_t m)
  * If the mallocator is empty, a new object is created,
  * by calling the function new_f().
  *
- * In both cases, the function reset_f() is called on the object.
+ * In both cases, the function reset_f() (if defined) is called on the object.
  *
  * \see xbt_mallocator_release()
  */
@@ -138,7 +137,8 @@ void *xbt_mallocator_get(xbt_mallocator_t m)
     object = m->new_f();
   }
 
-  m->reset_f(object);
+  if (m->reset_f)
+    m->reset_f(object);
   return object;
 }
 
index 928b3e5..8748245 100644 (file)
@@ -10,8 +10,8 @@
 #define _XBT_MALLOCATOR_PRIVATE_H__
 
 typedef struct s_xbt_mallocator {
-  int current_size;             /* number of objects currently stored */
   void **objects;               /* objects stored by the mallocator and available for the user */
+  int current_size;             /* number of objects currently stored */
   int max_size;                 /* maximum number of objects */
   pvoid_f_void_t new_f;         /* function to call when we are running out of objects */
   void_f_pvoid_t free_f;        /* function to call when we have got too many objects */
index 21c83eb..9158305 100644 (file)
@@ -71,7 +71,7 @@ static int _xbt_set_get_id(xbt_set_t set)
  *
  * \param set set to populate
  * \param elm element to add.
- * \param free_func How to add the data
+ * \param free_func how to free the data
  *
  * elm->name must be set;
  * if elm->name_len <= 0, it is recomputed. If >0, it's used as is;
index fcf6d3c..1eaaedf 100644 (file)
@@ -653,7 +653,7 @@ static int cmpstringp(const void *p1, const void *p2) {
 
   int res = strncmp(s1, s2, sort_len);
   if (res == 0)
-    return p1>p2;
+    res = p1 > p2 ? 1 : (p1 < p2 ? -1 : 0);
   return res;
 }