Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix java builds
[simgrid.git] / src / bindings / java / jmsg_host.cpp
index 6a095c5..7b45e78 100644 (file)
@@ -6,7 +6,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/plugins/energy.h"
-#include "simgrid/s4u/host.hpp"
+#include "simgrid/s4u/Host.hpp"
 
 #include "jmsg.h"
 #include "jmsg_host.h"
@@ -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)
 {
-  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");
-
-  if (!cls) {
+  if (!cls)
     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;
   }
 
-  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) {
-      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);