Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 21 Mar 2017 22:24:11 +0000 (23:24 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 22 Mar 2017 00:44:13 +0000 (01:44 +0100)
src/bindings/java/jmsg_host.cpp
src/msg/msg_host.cpp

index 6a095c5..938391c 100644 (file)
@@ -299,37 +299,28 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getStorageContent(JNIEn
 
 JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclass cls_arg)
 {
 
 JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclass cls_arg)
 {
-  int index;
-  jobjectArray jtable;
-  jobject jhost;
-  jstring jname;
-  msg_host_t host;
 
   xbt_dynar_t table =  MSG_hosts_as_dynar();
   int count = xbt_dynar_length(table);
 
   jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host");
 
   xbt_dynar_t table =  MSG_hosts_as_dynar();
   int count = xbt_dynar_length(table);
 
   jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host");
-
-  if (!cls) {
+  if (!cls)
     return nullptr;
     return nullptr;
-  }
 
 
-  jtable = env->NewObjectArray((jsize) count, cls, nullptr);
+  jobjectArray jtable = env->NewObjectArray((jsize)count, cls, nullptr);
 
   if (!jtable) {
     jxbt_throw_jni(env, "Hosts table allocation failed");
     return nullptr;
   }
 
 
   if (!jtable) {
     jxbt_throw_jni(env, "Hosts table allocation failed");
     return nullptr;
   }
 
-  for (index = 0; index < count; index++) {
-    host = xbt_dynar_get_as(table,index,msg_host_t);
-    jhost = (jobject) host->extension(JAVA_HOST_LEVEL);
+  for (int index = 0; index < count; index++) {
+    msg_host_t host = xbt_dynar_get_as(table, index, msg_host_t);
+    jobject jhost   = static_cast<jobject>(host->extension(JAVA_HOST_LEVEL));
 
     if (!jhost) {
 
     if (!jhost) {
-      jname = env->NewStringUTF(host->cname());
-
-      jhost = Java_org_simgrid_msg_Host_getByName(env, cls_arg, jname);
-      /* FIXME: leak of jname ? */
+      jstring jname = env->NewStringUTF(host->cname());
+      jhost         = Java_org_simgrid_msg_Host_getByName(env, cls_arg, jname);
     }
 
     env->SetObjectArrayElement(jtable, index, jhost);
     }
 
     env->SetObjectArrayElement(jtable, index, jhost);
index 51972e0..c34aeb1 100644 (file)
@@ -104,7 +104,7 @@ int MSG_get_host_number()
 }
 
 /** \ingroup m_host_management
 }
 
 /** \ingroup m_host_management
- * \brief Return a dynar containing all the hosts declared at a given point of time
+ * \brief Return a dynar containing all the hosts declared at a given point of time (including VMs)
  * \remark The host order in the returned array is generally different from the host creation/declaration order in the
  *         XML platform (we use a hash table internally)
  */
  * \remark The host order in the returned array is generally different from the host creation/declaration order in the
  *         XML platform (we use a hash table internally)
  */