Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
[simgrid.git] / src / bindings / java / jmsg_task.cpp
index add3877..953ec60 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions related to the java task instances.                            */
 
-/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2018. The SimGrid Team. All rights reserved.          */
 
 /* 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. */
@@ -15,8 +15,6 @@
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(java);
 
-extern "C" {
-
 static jmethodID jtask_method_Comm_constructor;
 
 static jfieldID jtask_field_Task_bind;
@@ -77,7 +75,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_parallelCreate(JNIEnv * env, jo
 
   jdouble* jcomputeDurations = env->GetDoubleArrayElements(jcomputeDurations_arg, 0);
   msg_host_t* hosts          = new msg_host_t[host_count];
-  double* computeDurations   = xbt_new0(double, host_count);
+  double* computeDurations   = new double[host_count];
   for (int index = 0; index < host_count; index++) {
     jobject jhost           = env->GetObjectArrayElement(jhosts, index);
     hosts[index] = jhost_get_native(env, jhost);
@@ -86,7 +84,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_parallelCreate(JNIEnv * env, jo
   env->ReleaseDoubleArrayElements(jcomputeDurations_arg, jcomputeDurations, 0);
 
   jdouble* jmessageSizes = env->GetDoubleArrayElements(jmessageSizes_arg, 0);
-  double* messageSizes   = xbt_new0(double, host_count* host_count);
+  double* messageSizes   = new double[host_count * host_count];
   for (int index = 0; index < host_count * host_count; index++) {
     messageSizes[index] = jmessageSizes[index];
   }
@@ -101,6 +99,8 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_parallelCreate(JNIEnv * env, jo
   jtask_bind(jtask, task, env);
 
   delete[] hosts;
+  delete[] computeDurations;
+  delete[] messageSizes;
 }
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_cancel(JNIEnv * env, jobject jtask)
@@ -203,7 +203,7 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Task_getFlopsAmount(JNIEnv * env,
     jxbt_throw_notbound(env, "task", jtask);
     return -1;
   }
-  return (jdouble) MSG_task_get_flops_amount(ptask);
+  return (jdouble)MSG_task_get_flops_amount(ptask);
 }
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setName(JNIEnv *env, jobject jtask, jobject jname) {
@@ -526,4 +526,3 @@ JNIEXPORT jint JNICALL Java_org_simgrid_msg_Task_listenFrom(JNIEnv * env, jclass
 
   return (jint) rv;
 }
-}