Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Replace a combination of malloc+strcpy by xbt_strdup.
authoragiersch <agiersch@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 22 Feb 2011 13:19:19 +0000 (13:19 +0000)
committeragiersch <agiersch@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 22 Feb 2011 13:19:19 +0000 (13:19 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9681 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/bindings/lua/lua_console.c
src/instr/jedule/jedule_events.c
src/instr/jedule/jedule_platform.c
src/surf/network.c
src/surf/network_im.c
tools/gras/windows_stub_generator.c

index abcc05e..da12ba5 100644 (file)
@@ -411,8 +411,7 @@ static int Route_new(lua_State * L)     // (src_id,dest_id,links_number,link_tab
 
      route->links_id = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
 
-     char *tmp_links = malloc(sizeof(char)*strlen(links)+1);//use xbt
-     strcpy(tmp_links,links);
+     char *tmp_links = xbt_strdup(links);
      link_id = strtok(tmp_links,",");   //tmp_link = strtok((char*)links,",");
      while(link_id != NULL)
        {
index 5075f4d..bab0e0c 100644 (file)
@@ -54,14 +54,12 @@ void create_jed_event(jed_event_t *event, char *name, double start_time,
                double end_time, const char *type) {
 
        *event = (jed_event_t) calloc(1, sizeof(s_jed_event_t));
-       (*event)->name = (char*) calloc(strlen(name) + 1, sizeof(char));
-       strcpy((*event)->name, name);
+       (*event)->name = xbt_strdup(name);
 
        (*event)->start_time = start_time;
        (*event)->end_time = end_time;
 
-       (*event)->type = (char*) calloc(strlen(type) + 1, sizeof(char));
-       strcpy((*event)->type, type);
+       (*event)->type = xbt_strdup(type);
 
        (*event)->resource_subsets = xbt_dynar_new(sizeof(jed_res_subset_t), NULL);
        (*event)->characteristics_list = xbt_dynar_new(sizeof(char*), NULL);
index 04d31b1..6ffefda 100644 (file)
@@ -66,8 +66,7 @@ void jed_simgrid_create_container(jed_simgrid_container_t *container, char *name
        xbt_assert( name != NULL );
 
        *container = (jed_simgrid_container_t)calloc(1,sizeof(s_jed_simgrid_container_t));
-       (*container)->name = (char*)calloc((strlen(name)+1), sizeof(char));
-       strcpy((*container)->name, name);
+       (*container)->name = xbt_strdup(name);
        (*container)->is_lowest = 0;
        (*container)->container_children = xbt_dynar_new(sizeof(jed_simgrid_container_t), NULL);
        (*container)->parent = NULL;
index 7a75d8b..3864fd9 100644 (file)
@@ -733,11 +733,9 @@ static surf_action_t net_communicate(const char *src_name,
   /* LARGE PLATFORMS HACK:
      expand also with src->link and dst->link */
 #ifdef HAVE_TRACING
-  action->src_name = xbt_new(char, strlen(src_name) + 1);
-  strncpy(action->src_name, src_name, strlen(src_name) + 1);
+  action->src_name = xbt_strdup(src_name);
 
-  action->dst_name = xbt_new(char, strlen(dst_name) + 1);
-  strncpy(action->dst_name, dst_name, strlen(dst_name) + 1);
+  action->dst_name = xbt_strdup(dst_name);
 #endif
 
   xbt_dynar_free(&route);
index 86e53b4..643a76e 100644 (file)
@@ -783,11 +783,9 @@ static surf_action_t im_net_communicate(const char *src_name,
   /* LARGE PLATFORMS HACK:
      expand also with src->link and dst->link */
 #ifdef HAVE_TRACING
-  action->src_name = xbt_new(char, strlen(src_name) + 1);
-  strncpy(action->src_name, src_name, strlen(src_name) + 1);
+  action->src_name = xbt_strdup(src_name);
 
-  action->dst_name = xbt_new(char, strlen(dst_name) + 1);
-  strncpy(action->dst_name, dst_name, strlen(dst_name) + 1);
+  action->dst_name = xbt_strdup(dst_name);
 #endif
 
   xbt_dynar_free(&route);
index 585ba12..77a9fe9 100644 (file)
@@ -660,9 +660,7 @@ void generate_borland_simulation_project(const char *name)
 
   GetCurrentDirectory(MAX_PATH, buffer);
 
-  borland_project.src_dir = xbt_new0(char, strlen(buffer) + 1);
-
-  strcpy(borland_project.src_dir, buffer);
+  borland_project.src_dir = xbt_strdup(buffer);
 
   borland_project.name =
       xbt_new0(char, strlen(name) + strlen("simulator") + 2);
@@ -717,9 +715,7 @@ void generate_borland_real_life_project(const char *name)
 
   GetCurrentDirectory(MAX_PATH, buffer);
 
-  borland_project.src_dir = xbt_new0(char, strlen(buffer) + 1);
-
-  strcpy(borland_project.src_dir, buffer);
+  borland_project.src_dir = xbt_strdup(buffer);
 
   borland_project.bin_dir =
       xbt_new0(char, strlen(buffer) + strlen("\\bin") + 1);
@@ -838,8 +834,7 @@ int generate_simulation_dsp_file(const char *name)
   GetEnvironmentVariable("LIB_SIMGRID_PATH", dsp.lib_dir, MAX_PATH);
   GetCurrentDirectory(MAX_PATH, buffer);
 
-  dsp.src_dir = xbt_new0(char, strlen(buffer) + 1);
-  strcpy(dsp.src_dir, buffer);
+  dsp.src_dir = xbt_strdup(buffer);
   dsp.name = xbt_new0(char, strlen(name) + strlen("simulator") + 2);
   sprintf(dsp.name, "%s_simulator", name);
 
@@ -871,9 +866,7 @@ int generate_real_live_dsp_file(const char *name)
 
   GetCurrentDirectory(MAX_PATH, buffer);
 
-  dsp.src_dir = xbt_new0(char, strlen(buffer) + 1);
-
-  strcpy(dsp.src_dir, buffer);
+  dsp.src_dir = xbt_strdup(buffer);
 
 
   xbt_dict_foreach(process_function_set, cursor, key, data) {