From 774072f2835d79ac708e3485d95492293e722bbd Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 21 Mar 2017 23:24:11 +0100 Subject: [PATCH] cosmetics --- src/bindings/java/jmsg_host.cpp | 23 +++++++---------------- src/msg/msg_host.cpp | 2 +- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/bindings/java/jmsg_host.cpp b/src/bindings/java/jmsg_host.cpp index 6a095c5e2e..938391c5c2 100644 --- a/src/bindings/java/jmsg_host.cpp +++ b/src/bindings/java/jmsg_host.cpp @@ -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(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); diff --git a/src/msg/msg_host.cpp b/src/msg/msg_host.cpp index 51972e0526..c34aeb14c6 100644 --- a/src/msg/msg_host.cpp +++ b/src/msg/msg_host.cpp @@ -104,7 +104,7 @@ int MSG_get_host_number() } /** \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) */ -- 2.20.1