X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/68422deb1639b1ce574393779ae259579be53fb5..39423c5e63cbaa7fc3c41a4af6037948c4033225:/src/bindings/java/jmsg_task.cpp diff --git a/src/bindings/java/jmsg_task.cpp b/src/bindings/java/jmsg_task.cpp index f3df89157a..d6151845eb 100644 --- a/src/bindings/java/jmsg_task.cpp +++ b/src/bindings/java/jmsg_task.cpp @@ -5,7 +5,7 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include +#include "simgrid/s4u/Host.hpp" #include "jmsg.h" #include "jmsg_host.h" @@ -327,11 +327,10 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_irecv(JNIEnv * env, jclass c JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receiveBounded(JNIEnv* env, jclass cls, jstring jalias, jdouble jtimeout, jdouble rate) { - msg_task_t *task = xbt_new(msg_task_t,1); - *task = nullptr; + msg_task_t task = nullptr; const char *alias = env->GetStringUTFChars(jalias, 0); - msg_error_t res = MSG_task_receive_ext_bounded(task, alias, static_cast(jtimeout), /*host*/ nullptr, + msg_error_t res = MSG_task_receive_ext_bounded(&task, alias, static_cast(jtimeout), /*host*/ nullptr, static_cast(rate)); if (env->ExceptionOccurred()) return nullptr; @@ -339,17 +338,15 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receiveBounded(JNIEnv* env, jmsg_throw_status(env, res); return nullptr; } - jobject jtask_global = (jobject) MSG_task_get_data(*task); + jobject jtask_global = (jobject)MSG_task_get_data(task); /* Convert the global ref into a local ref so that the JVM can free the stuff */ jobject jtask_local = env->NewLocalRef(jtask_global); env->DeleteGlobalRef(jtask_global); - MSG_task_set_data(*task, nullptr); + MSG_task_set_data(task, nullptr); env->ReleaseStringUTFChars(jalias, alias); - xbt_free(task); - return (jobject) jtask_local; }