Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use xbt_strdup instead of strdup
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 9 Jun 2015 14:37:07 +0000 (16:37 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 9 Jun 2015 14:37:07 +0000 (16:37 +0200)
12 files changed:
src/bindings/java/jmsg.c
src/bindings/java/jmsg_host.c
src/bindings/java/jmsg_storage.c
src/instr/jedule/jedule_platform.c
src/mc/mc_comm_pattern.cpp
src/mc/mc_process.cpp
src/smpi/smpi_mpi_dt.c
src/smpi/smpi_rma.c
src/xbt/automaton/automaton.c
src/xbt/automaton/automatonparse_promela.c
src/xbt/dict.c
src/xbt/dynar.c

index b5a7abb..685e2b3 100644 (file)
@@ -124,12 +124,12 @@ Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs)
 
   argc++;
   argv = xbt_new(char *, argc + 1);
-  argv[0] = strdup("java");
+  argv[0] = xbt_strdup("java");
 
   for (index = 0; index < argc - 1; index++) {
     jval = (jstring) (*env)->GetObjectArrayElement(env, jargs, index);
     tmp = (*env)->GetStringUTFChars(env, jval, 0);
-    argv[index + 1] = strdup(tmp);
+    argv[index + 1] = xbt_strdup(tmp);
     (*env)->ReleaseStringUTFChars(env, jval, tmp);
   }
   argv[argc] = NULL;
@@ -320,4 +320,3 @@ static int create_jprocess(int argc, char *argv[]) {
 
   return 0;
 }
-
index 7c013ea..d0ac0be 100644 (file)
@@ -245,7 +245,7 @@ Java_org_simgrid_msg_Host_setProperty(JNIEnv *env, jobject jhost, jobject jname,
   }
   const char *name = (*env)->GetStringUTFChars(env, jname, 0);
   const char *value_java = (*env)->GetStringUTFChars(env, jvalue, 0);
-  char *value = strdup(value_java);
+  char *value = xbt_strdup(value_java);
 
   MSG_host_set_property_value(host, name, value, xbt_free_f);
 
index 0fee6cd..71dabb5 100644 (file)
@@ -176,7 +176,7 @@ Java_org_simgrid_msg_Storage_setProperty(JNIEnv *env, jobject jstorage, jobject
   }
   const char *name = (*env)->GetStringUTFChars(env, jname, 0);
   const char *value_java = (*env)->GetStringUTFChars(env, jvalue, 0);
-  char *value = strdup(value_java);
+  char *value = xbt_strdup(value_java);
 
   MSG_storage_set_property_value(storage, name, value, xbt_free_f);
 
@@ -241,4 +241,3 @@ Java_org_simgrid_msg_Storage_all(JNIEnv * env, jclass cls_arg)
   xbt_dynar_free(&table);
   return jtable;
 }
-
index 9a3fe8a..38a3ef4 100644 (file)
@@ -258,7 +258,7 @@ void jedule_add_meta_info(jedule_t jedule, char *key, char *value) {
   xbt_assert(key != NULL);
   xbt_assert(value != NULL);
 
-  val_cp = strdup(value);
+  val_cp = xbt_strdup(value);
   xbt_dict_set(jedule->jedule_meta_info, key, val_cp, NULL);
 }
 
index f63a529..96b53fc 100644 (file)
@@ -26,7 +26,7 @@ mc_comm_pattern_t MC_comm_pattern_dup(mc_comm_pattern_t comm)
   res->index = comm->index;
   res->type = comm->type;
   res->comm_addr = comm->comm_addr;
-  res->rdv = strdup(comm->rdv);
+  res->rdv = xbt_strdup(comm->rdv);
   res->data_size = -1;
   res->data = NULL;
   if (comm->type == SIMIX_COMM_SEND) {
index 381d55b..d5234e0 100644 (file)
@@ -480,7 +480,7 @@ char* Process::read_string(remote_ptr<void> address) const
   if (!address)
     return NULL;
   if (this->is_self())
-    return strdup((char*) address.address());
+    return xbt_strdup((char*) address.address());
 
   off_t len = 128;
   char* res = (char*) malloc(len);
index dd279e6..f5266ae 100644 (file)
@@ -187,7 +187,7 @@ int smpi_datatype_dup(MPI_Datatype datatype, MPI_Datatype* new_t)
     memcpy((*new_t)->substruct, datatype->substruct, sizeof(s_smpi_mpi_struct_t));
   }
   if(datatype->name)
-    (*new_t)->name = strdup(datatype->name);
+    (*new_t)->name = xbt_strdup(datatype->name);
   if(datatype->attributes !=NULL){
       (*new_t)->attributes=xbt_dict_new();
       xbt_dict_cursor_t cursor = NULL;
@@ -237,7 +237,7 @@ void smpi_datatype_get_name(MPI_Datatype datatype, char* name, int* length){
 }
 
 void smpi_datatype_set_name(MPI_Datatype datatype, char* name){
-  datatype->name = strdup(name);;
+  datatype->name = xbt_strdup(name);;
 }
 
 int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
@@ -1779,4 +1779,3 @@ int smpi_mpi_unpack(void* inbuf, int insize, int* position, void* outbuf, int ou
   *position += outcount * size;
   return MPI_SUCCESS;
 }
-
index b35bc1a..77d4795 100644 (file)
@@ -111,7 +111,7 @@ void smpi_mpi_win_get_group(MPI_Win win, MPI_Group* group){
 }
 
 void smpi_mpi_win_set_name(MPI_Win win, char* name){
-  win->name = strdup(name);;
+  win->name = xbt_strdup(name);;
 }
 
 
@@ -440,6 +440,3 @@ int smpi_mpi_win_wait(MPI_Win win){
   win->opened--; //we're opened for business !
   return MPI_SUCCESS;
 }
-
-
-
index a961720..7fc979a 100644 (file)
@@ -33,7 +33,7 @@ xbt_automaton_state_t xbt_automaton_state_new(xbt_automaton_t a, int type, char*
   xbt_automaton_state_t state = NULL;
   state = xbt_new0(struct xbt_automaton_state, 1);
   state->type = type;
-  state->id = strdup(id);
+  state->id = xbt_strdup(id);
   state->in = xbt_dynar_new(sizeof(xbt_automaton_transition_t), xbt_automaton_transition_free_voidp);
   state->out = xbt_dynar_new(sizeof(xbt_automaton_transition_t), xbt_automaton_transition_free_voidp); 
   xbt_dynar_push(a->states, &state);
@@ -85,7 +85,7 @@ xbt_automaton_exp_label_t xbt_automaton_exp_label_new(int type, ...){
   }
   case 3 :{
     char* p = va_arg(ap, char*);
-    label->u.predicat = strdup(p);
+    label->u.predicat = xbt_strdup(p);
     break;
   }
   }
@@ -216,7 +216,7 @@ static int call_simple_function(void* function)
 xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new(xbt_automaton_t a, const char* id, int(*fct)(void)){
   xbt_automaton_propositional_symbol_t prop_symb = NULL;
   prop_symb = xbt_new0(struct xbt_automaton_propositional_symbol, 1);
-  prop_symb->pred = strdup(id);
+  prop_symb->pred = xbt_strdup(id);
   prop_symb->callback = call_simple_function;
   prop_symb->data = fct;
   prop_symb->free_function = NULL;
@@ -228,7 +228,7 @@ XBT_PUBLIC(xbt_automaton_propositional_symbol_t) xbt_automaton_propositional_sym
 {
   xbt_automaton_propositional_symbol_t prop_symb = NULL;
   prop_symb = xbt_new0(struct xbt_automaton_propositional_symbol, 1);
-  prop_symb->pred = strdup(id);
+  prop_symb->pred = xbt_strdup(id);
   prop_symb->callback = NULL;
   prop_symb->data = value;
   prop_symb->free_function = NULL;
@@ -243,7 +243,7 @@ XBT_PUBLIC(xbt_automaton_propositional_symbol_t) xbt_automaton_propositional_sym
 {
   xbt_automaton_propositional_symbol_t prop_symb = NULL;
   prop_symb = xbt_new0(struct xbt_automaton_propositional_symbol, 1);
-  prop_symb->pred = strdup(id);
+  prop_symb->pred = xbt_strdup(id);
   prop_symb->callback = callback;
   prop_symb->data = data;
   prop_symb->free_function = free_function;
index 7e73dd7..5227070 100644 (file)
@@ -15,7 +15,7 @@ char* state_id_src;
 
 static void new_state(char* id, int src){
 
-  char* id_state = strdup(id);
+  char* id_state = xbt_strdup(id);
   char* first_part = strtok(id,"_");
   int type = 0 ; // -1=initial state; 0=intermediate state; 1=final state
 
@@ -38,13 +38,13 @@ static void new_state(char* id, int src){
     parsed_automaton->current_state = state;
 
   if(src)
-    state_id_src = strdup(id_state);
+    state_id_src = xbt_strdup(id_state);
     
 }
 
 static void new_transition(char* id, xbt_automaton_exp_label_t label){
 
-  char* id_state = strdup(id);
+  char* id_state = xbt_strdup(id);
   xbt_automaton_state_t state_dst = NULL;
   new_state(id, 0);
   state_dst = xbt_automaton_state_exists(parsed_automaton, id_state);
index 7259a19..d59086b 100644 (file)
@@ -892,19 +892,19 @@ static void basic_test(int homogeneous)
   fill(&head, homogeneous);
   count_check_get_key(head, 7);
   xbt_test_add("Change 123 to 'Changed 123'");
-  xbt_dict_set(head, "123", strdup("Changed 123"), free_f);
+  xbt_dict_set(head, "123", xbt_strdup("Changed 123"), free_f);
   count_check_get_key(head, 7);
 
   xbt_test_add("Change 123 back to '123'");
-  xbt_dict_set(head, "123", strdup("123"), free_f);
+  xbt_dict_set(head, "123", xbt_strdup("123"), free_f);
   count_check_get_key(head, 7);
 
   xbt_test_add("Change 12a to 'Dummy 12a'");
-  xbt_dict_set(head, "12a", strdup("Dummy 12a"), free_f);
+  xbt_dict_set(head, "12a", xbt_strdup("Dummy 12a"), free_f);
   count_check_get_key(head, 7);
 
   xbt_test_add("Change 12a to '12a'");
-  xbt_dict_set(head, "12a", strdup("12a"), free_f);
+  xbt_dict_set(head, "12a", xbt_strdup("12a"), free_f);
   count_check_get_key(head, 7);
 
   xbt_test_add("Traverse the resulting dictionary");
index e591967..fc937cb 100644 (file)
@@ -1140,22 +1140,22 @@ XBT_TEST_UNIT("string", test_dynar_string, "Dynars of strings")
   /* 1. Populate the dynar */
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
     sprintf(buf, "%d", cpt);
-    s1 = strdup(buf);
+    s1 = xbt_strdup(buf);
     xbt_dynar_push(d, &s1);
   }
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
     sprintf(buf, "%d", cpt);
-    s1 = strdup(buf);
+    s1 = xbt_strdup(buf);
     xbt_dynar_replace(d, cpt, &s1);
   }
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
     sprintf(buf, "%d", cpt);
-    s1 = strdup(buf);
+    s1 = xbt_strdup(buf);
     xbt_dynar_replace(d, cpt, &s1);
   }
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
     sprintf(buf, "%d", cpt);
-    s1 = strdup(buf);
+    s1 = xbt_strdup(buf);
     xbt_dynar_replace(d, cpt, &s1);
   }
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
@@ -1174,7 +1174,7 @@ XBT_TEST_UNIT("string", test_dynar_string, "Dynars of strings")
   d = xbt_dynar_new(sizeof(char **), &xbt_free_ref);
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
     sprintf(buf, "%d", cpt);
-    s1 = strdup(buf);
+    s1 = xbt_strdup(buf);
     xbt_dynar_unshift(d, &s1);
   }
   /* 2. Traverse the dynar with the macro */
@@ -1205,12 +1205,12 @@ XBT_TEST_UNIT("string", test_dynar_string, "Dynars of strings")
   d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
     sprintf(buf, "%d", cpt);
-    s1 = strdup(buf);
+    s1 = xbt_strdup(buf);
     xbt_dynar_push(d, &s1);
   }
   for (cpt = 0; cpt < NB_ELEM / 5; cpt++) {
     sprintf(buf, "%d", cpt);
-    s1 = strdup(buf);
+    s1 = xbt_strdup(buf);
     xbt_dynar_insert_at(d, NB_ELEM / 2, &s1);
   }
 
@@ -1248,7 +1248,7 @@ XBT_TEST_UNIT("string", test_dynar_string, "Dynars of strings")
   d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
   for (cpt = 0; cpt < NB_ELEM; cpt++) {
     sprintf(buf, "%d", cpt);
-    s1 = strdup(buf);
+    s1 = xbt_strdup(buf);
     xbt_dynar_push(d, &s1);
   }
   for (cpt = 2 * (NB_ELEM / 5); cpt < 4 * (NB_ELEM / 5); cpt++) {