JNIEnv *env;
XBT_ATTRIB_UNUSED jint error =
- __java_vm->AttachCurrentThread((void **) &env, NULL);
+ __java_vm->AttachCurrentThread((void **) &env, nullptr);
xbt_assert((error == JNI_OK), "The thread could not be attached to the JVM");
context->jenv = get_current_thread_env();
//Wait for the first scheduling round to happen.
XBT_ATTRIB_UNUSED jint error = __java_vm->DetachCurrentThread();
xbt_assert((error == JNI_OK), "The thread couldn't be detached.");
xbt_os_sem_release(this->end);
- xbt_os_thread_exit(NULL);
+ xbt_os_thread_exit(nullptr);
}
}
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
-JavaVM *__java_vm = NULL;
+JavaVM *__java_vm = nullptr;
JavaVM *get_java_VM(void)
{
{
JNIEnv *env;
- __java_vm->AttachCurrentThread((void **) &env, NULL);
+ __java_vm->AttachCurrentThread((void **) &env, nullptr);
return env;
}
void jmsg_throw_status(JNIEnv *env, msg_error_t status) {
switch (status) {
case MSG_TIMEOUT:
- jxbt_throw_time_out_failure(env,NULL);
+ jxbt_throw_time_out_failure(env,nullptr);
break;
case MSG_TRANSFER_FAILURE:
- jxbt_throw_transfer_failure(env,NULL);
+ jxbt_throw_transfer_failure(env,nullptr);
break;
case MSG_HOST_FAILURE:
- jxbt_throw_host_failure(env,NULL);
+ jxbt_throw_host_failure(env,nullptr);
break;
case MSG_TASK_CANCELED:
- jxbt_throw_task_cancelled(env,NULL);
+ jxbt_throw_task_cancelled(env,nullptr);
break;
default:
jxbt_throw_native(env,xbt_strdup("undefined message failed "
JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs)
{
- char **argv = NULL;
+ char **argv = nullptr;
int index;
int argc = 0;
jstring jval;
argv[index + 1] = xbt_strdup(tmp);
env->ReleaseStringUTFChars(jval, tmp);
}
- argv[argc] = NULL;
+ argv[argc] = nullptr;
MSG_init(&argc, argv);
jobject jas = jas_new_instance(env);
if (!jas) {
jxbt_throw_jni(env, "java As instantiation failed");
- return NULL;
+ return nullptr;
}
jas = jas_ref(env, jas);
if (!jas) {
jxbt_throw_jni(env, "new global ref allocation failed");
- return NULL;
+ return nullptr;
}
jas_bind(jas, as, env);
jclass class_Process = env->FindClass(argv[0]);
xbt_str_subst(argv[0],'/','.',0);
//Retrieve the methodID for the constructor
- xbt_assert((class_Process != NULL), "Class not found (%s). The deployment file must use the fully qualified class name, including the package. The case is important.", argv[0]);
+ xbt_assert((class_Process != nullptr), "Class not found (%s). The deployment file must use the fully qualified class name, including the package. The case is important.", argv[0]);
jmethodID constructor_Process = env->GetMethodID(class_Process, "<init>", "(Lorg/simgrid/msg/Host;Ljava/lang/String;[Ljava/lang/String;)V");
- xbt_assert((constructor_Process != NULL), "Constructor not found for class %s. Is there a (Host, String ,String[]) constructor in your class ?", argv[0]);
+ xbt_assert((constructor_Process != nullptr), "Constructor not found for class %s. Is there a (Host, String ,String[]) constructor in your class ?", argv[0]);
//Retrieve the name of the process.
jstring jname = env->NewStringUTF(argv[0]);
env->SetObjectArrayElement(args,i - 1, env->NewStringUTF(argv[i]));
//Retrieve the host for the process.
jstring jhostName = env->NewStringUTF(MSG_host_get_name(MSG_host_self()));
- jobject jhost = Java_org_simgrid_msg_Host_getByName(env, NULL, jhostName);
+ jobject jhost = Java_org_simgrid_msg_Host_getByName(env, nullptr, jhostName);
//creates the process
jobject jprocess = env->NewObject(class_Process, constructor_Process, jhost, jname, args);
- xbt_assert((jprocess != NULL), "Process allocation failed.");
+ xbt_assert((jprocess != nullptr), "Process allocation failed.");
jprocess = env->NewGlobalRef(jprocess);
//bind the process to the context
msg_process_t process = MSG_process_self();
jclass cls = env->FindClass("org/simgrid/msg/As");
if (!cls) {
- return NULL;
+ return nullptr;
}
- jtable = env->NewObjectArray((jsize) count, cls, NULL);
+ jtable = env->NewObjectArray((jsize) count, cls, nullptr);
if (!jtable) {
jxbt_throw_jni(env, "Hosts table allocation failed");
- return NULL;
+ return nullptr;
}
- xbt_dict_cursor_t cursor=NULL;
+ xbt_dict_cursor_t cursor=nullptr;
char *key;
xbt_dict_foreach(dict,cursor,key,tmp_as) {
tmp_jas = jas_new_instance(env);
if (!tmp_jas) {
jxbt_throw_jni(env, "java As instantiation failed");
- return NULL;
+ return nullptr;
}
tmp_jas = jas_ref(env, tmp_jas);
if (!tmp_jas) {
jxbt_throw_jni(env, "new global ref allocation failed");
- return NULL;
+ return nullptr;
}
jas_bind(tmp_jas, tmp_as, env);
if (!as) {
jxbt_throw_notbound(env, "as", jas);
- return NULL;
+ return nullptr;
}
const char *name = env->GetStringUTFChars((jstring) jname, 0);
const char *property = MSG_environment_as_get_property_value(as, name);
if (!property) {
- return NULL;
+ return nullptr;
}
jobject jproperty = env->NewStringUTF(property);
jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host");
if (!cls) {
- return NULL;
+ return nullptr;
}
- jtable = env->NewObjectArray((jsize) count, cls, NULL);
+ jtable = env->NewObjectArray((jsize) count, cls, nullptr);
if (!jtable) {
jxbt_throw_jni(env, "Hosts table allocation failed");
- return NULL;
+ return nullptr;
}
for (index = 0; index < count; index++) {
if (jreceiving == JNI_TRUE) {
//bind the task object.
msg_task_t task = MSG_comm_get_task(comm);
- xbt_assert(task != NULL, "Task is NULL");
+ xbt_assert(task != nullptr, "Task is nullptr");
jobject jtask_global = (jobject) MSG_task_get_data(task);
//case where the data has already been retrieved
- if (jtask_global == NULL) {
+ if (jtask_global == nullptr) {
return;
}
env->SetObjectField(jcomm, jtask_field_Comm_task, jtask_local);
- MSG_task_set_data(task, NULL);
+ MSG_task_set_data(task, nullptr);
}
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_File_nativeInit(JNIEnv *env, jclass cls) {
jclass class_File = env->FindClass("org/simgrid/msg/File");
jfile_field_bind = jxbt_get_jfield(env , class_File, "bind", "J");
- xbt_assert((jfile_field_bind != NULL), "Can't find \"bind\" field in File class.");
+ xbt_assert((jfile_field_bind != nullptr), "Can't find \"bind\" field in File class.");
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_File_open(JNIEnv *env, jobject jfile, jobject jpath) {
const char *path = env->GetStringUTFChars((jstring) jpath, 0);
msg_file_t file;
- file = MSG_file_open(path, NULL);
+ file = MSG_file_open(path, nullptr);
jfile_bind(env, jfile, file);
env->ReleaseStringUTFChars((jstring) jpath, path);
msg_file_t file = jfile_get_native(env, jfile);
MSG_file_close(file);
- jfile_bind(env, jfile, NULL);
+ jfile_bind(env, jfile, nullptr);
}
jobject jhost; /* global reference to the java host instance returned */
/* get the C string from the java string */
- if (jname == NULL) {
+ if (jname == nullptr) {
jxbt_throw_null(env,bprintf("No host can have a null name"));
- return NULL;
+ return nullptr;
}
const char *name = env->GetStringUTFChars(jname, 0);
/* get the host by name (the hosts are created during the grid resolution) */
if (!host) { /* invalid name */
jxbt_throw_host_not_found(env, name);
env->ReleaseStringUTFChars(jname, name);
- return NULL;
+ return nullptr;
}
env->ReleaseStringUTFChars(jname, name);
if (!jhost) {
jxbt_throw_jni(env, "java host instantiation failed");
- return NULL;
+ return nullptr;
}
/* get a global reference to the newly created host */
if (!jhost) {
jxbt_throw_jni(env, "new global ref allocation failed");
- return NULL;
+ return nullptr;
}
/* Sets the java host name */
env->SetObjectField(jhost, jhost_field_Host_name, jname);
if (!jhost) {
jxbt_throw_jni(env, "java host instantiation failed");
- return NULL;
+ return nullptr;
}
/* get a global reference to the newly created host */
if (!jhost) {
jxbt_throw_jni(env, "global ref allocation failed");
- return NULL;
+ return nullptr;
}
/* Sets the host name */
const char *name = MSG_host_get_name(host);
if (!host) {
jxbt_throw_notbound(env, "host", jhost);
- return NULL;
+ return nullptr;
}
const char *name = env->GetStringUTFChars((jstring) jname, 0);
const char *property = MSG_host_get_property_value(host, name);
if (!property) {
- return NULL;
+ return nullptr;
}
jobject jproperty = env->NewStringUTF(property);
int count = xbt_dict_length(dict);
jclass cls = env->FindClass("org/simgrid/msg/Storage");
- jtable = env->NewObjectArray((jsize) count, cls, NULL);
+ jtable = env->NewObjectArray((jsize) count, cls, nullptr);
if (!jtable) {
jxbt_throw_jni(env, "Storages table allocation failed");
- return NULL;
+ return nullptr;
}
- xbt_dict_cursor_t cursor=NULL;
+ xbt_dict_cursor_t cursor=nullptr;
const char* mount_name;
const char* storage_name;
xbt_dynar_t dyn = MSG_host_get_attached_storage_list(host);
int count = xbt_dynar_length(dyn);
jclass cls = jxbt_get_class(env, "java/lang/String");
- jtable = env->NewObjectArray((jsize) count, cls, NULL);
+ jtable = env->NewObjectArray((jsize) count, cls, nullptr);
int index;
char *storage_name;
jstring jstorage_name;
jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host");
if (!cls) {
- return NULL;
+ return nullptr;
}
- jtable = env->NewObjectArray((jsize) count, cls, NULL);
+ jtable = env->NewObjectArray((jsize) count, cls, nullptr);
if (!jtable) {
jxbt_throw_jni(env, "Hosts table allocation failed");
- return NULL;
+ return nullptr;
}
for (index = 0; index < count; index++) {
{
msg_process_t process = jprocess_to_native_process(jprocess,env);
simgrid::java::JavaContext* context = (simgrid::java::JavaContext*) MSG_process_get_smx_ctx(process);
- xbt_os_thread_join(context->thread,NULL);
+ xbt_os_thread_join(context->thread,nullptr);
}
msg_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env)
jname = jprocess_get_name(jprocess_arg, env);
if (!jname) {
jxbt_throw_null(env,
- xbt_strdup("Internal error: Process name cannot be NULL"));
+ xbt_strdup("Internal error: Process name cannot be nullptr"));
return;
}
}, jprocess,
host,
/*argc, argv, properties*/
- 0, NULL, NULL);
+ 0, nullptr, nullptr);
MSG_process_set_kill_time(process, (double)jkill);
/* bind the java process instance to the native process */
jprocess_bind(jprocess, process, env);
env->SetIntField(jprocess, jprocess_field_Process_pid,(jint) MSG_process_get_PID(process));
env->SetIntField(jprocess, jprocess_field_Process_ppid, (jint) MSG_process_get_PPID(process));
/* sets the Host of the process */
- jobject jhost = Java_org_simgrid_msg_Host_getByName(env,NULL, (jstring)jhostname);
+ jobject jhost = Java_org_simgrid_msg_Host_getByName(env,nullptr, (jstring)jhostname);
env->SetObjectField(jprocess, jprocess_field_Process_host, jhost);
}
if (!process) {
jxbt_throw_process_not_found(env, bprintf("PID = %d",(int) PID));
- return NULL;
+ return nullptr;
}
jobject jprocess = native_to_java_process(process);
if (!jprocess) {
jxbt_throw_jni(env, "get process failed");
- return NULL;
+ return nullptr;
}
return jprocess;
if (!process) {
jxbt_throw_notbound(env, "process", jprocess);
- return NULL;
+ return nullptr;
}
const char *name = env->GetStringUTFChars((jstring)jname, 0);
const char *property = MSG_process_get_property_value(process, name);
if (!property) {
- return NULL;
+ return nullptr;
}
jobject jproperty = env->NewStringUTF(property);
if (!process) {
jxbt_throw_jni(env, xbt_strdup("MSG_process_self() failed"));
- return NULL;
+ return nullptr;
}
jprocess = native_to_java_process(process);
// is a cancelled_error, see bindings/java/smx_context_java.c, function void smx_ctx_java_stop(smx_context_t context) and src/msg/msg_gos.c
// function msg_error_t MSG_process_sleep(double nb_sec)
- jxbt_throw_host_failure(env,NULL);
+ jxbt_throw_host_failure(env,nullptr);
}
}
RngStream rngstream = (RngStream)(intptr_t)env->GetLongField(jrngstream, jrngstream_bind);
if (!rngstream) {
jxbt_throw_notbound(env, "rngstream", jrngstream);
- return NULL;
+ return nullptr;
}
return rngstream;
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_nativeFinalize(JNIEnv *env, jobject jrngstream) {
RngStream rngstream = jrngstream_to_native(env, jrngstream);
RngStream_DeleteStream(&rngstream);
- env->SetLongField(jrngstream, jrngstream_bind, (intptr_t)NULL);
+ env->SetLongField(jrngstream, jrngstream_bind, (intptr_t)nullptr);
}
JNIEXPORT jboolean JNICALL
jobject jstorage;
/* get the C string from the java string */
- if (jname == NULL) {
+ if (jname == nullptr) {
jxbt_throw_null(env,bprintf("No host can have a null name"));
- return NULL;
+ return nullptr;
}
const char *name = env->GetStringUTFChars(jname, 0);
storage = MSG_storage_get_by_name(name);
if (!storage) { /* invalid name */
jxbt_throw_storage_not_found(env, name);
env->ReleaseStringUTFChars(jname, name);
- return NULL;
+ return nullptr;
}
env->ReleaseStringUTFChars(jname, name);
if (!jstorage) {
jxbt_throw_jni(env, "java storage instantiation failed");
- return NULL;
+ return nullptr;
}
/* get a global reference to the newly created storage */
if (!jstorage) {
jxbt_throw_jni(env, "new global ref allocation failed");
- return NULL;
+ return nullptr;
}
/* Sets the java storage name */
env->SetObjectField(jstorage, jstorage_field_Storage_name, jname);
if (!storage) {
jxbt_throw_notbound(env, "storage", jstorage);
- return NULL;
+ return nullptr;
}
const char *name = env->GetStringUTFChars((jstring) jname, 0);
const char *property = MSG_storage_get_property_value(storage, name);
if (!property) {
- return NULL;
+ return nullptr;
}
jobject jproperty = env->NewStringUTF(property);
if (!storage) {
jxbt_throw_notbound(env, "storage", jstorage);
- return NULL;
+ return nullptr;
}
const char *host_name = MSG_storage_get_host(storage);
if (!host_name) {
- return NULL;
+ return nullptr;
}
jobject jhost_name = env->NewStringUTF(host_name);
jclass cls = jxbt_get_class(env, "org/simgrid/msg/Storage");
if (!cls) {
- return NULL;
+ return nullptr;
}
- jtable = env->NewObjectArray((jsize) count, cls, NULL);
+ jtable = env->NewObjectArray((jsize) count, cls, nullptr);
if (!jtable) {
jxbt_throw_jni(env, "Storages table allocation failed");
- return NULL;
+ return nullptr;
}
for (index = 0; index < count; index++) {
jdouble jflopsAmount, jdouble jbytesAmount)
{
msg_task_t task; /* the native task to create */
- const char *name = NULL; /* the name of the task */
+ const char *name = nullptr; /* the name of the task */
if (jflopsAmount < 0) {
jxbt_throw_illegal(env, bprintf("Task flopsAmount (%f) cannot be negative", (double) jflopsAmount));
}
/* create the task */
- task = MSG_task_create(name, (double) jflopsAmount, (double) jbytesAmount, NULL);
+ task = MSG_task_create(name, (double) jflopsAmount, (double) jbytesAmount, nullptr);
if (jname)
env->ReleaseStringUTFChars(jname, name);
/* sets the task name */
/* get the C string from the java string */
name = env->GetStringUTFChars(jname, 0);
- task = MSG_parallel_task_create(name, host_count, hosts, computeDurations, messageSizes, NULL);
+ task = MSG_parallel_task_create(name, host_count, hosts, computeDurations, messageSizes, nullptr);
env->ReleaseStringUTFChars(jname, name);
/* sets the task name */
if (!task) {
jxbt_throw_notbound(env, "task", jtask);
- return NULL;
+ return nullptr;
}
return env->NewStringUTF(MSG_task_get_name(task));
if (!task) {
jxbt_throw_notbound(env, "task", jtask);
- return NULL;
+ return nullptr;
}
process = MSG_task_get_sender(task);
- if (process == NULL) {
- return NULL;
+ if (process == nullptr) {
+ return nullptr;
}
return (jobject) native_to_java_process(process);
}
if (!task) {
jxbt_throw_notbound(env, "task", jtask);
- return NULL;
+ return nullptr;
}
host = MSG_task_get_source(task);
- if (host == NULL) {
- return NULL;
+ if (host == nullptr) {
+ return nullptr;
}
if (!host->extension(JAVA_HOST_LEVEL)) {
jxbt_throw_jni(env, "MSG_task_get_source() failed");
- return NULL;
+ return nullptr;
}
return (jobject) host->extension(JAVA_HOST_LEVEL);
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receive(JNIEnv * env, jclass cls, jstring jalias, jdouble jtimeout,
jobject jhost)
{
- msg_task_t task = NULL;
+ msg_task_t task = nullptr;
- msg_host_t host = NULL;
+ msg_host_t host = nullptr;
jobject jtask_global, jtask_local;
if (jhost) {
if (!host) {
jxbt_throw_notbound(env, "host", jhost);
- return NULL;
+ return nullptr;
}
}
const char *alias = env->GetStringUTFChars(jalias, 0);
msg_error_t rv = MSG_task_receive_ext(&task, alias, (double) jtimeout, host);
if (env->ExceptionOccurred())
- return NULL;
+ return nullptr;
if (rv != MSG_OK) {
jmsg_throw_status(env,rv);
- return NULL;
+ return nullptr;
}
jtask_global = (jobject) MSG_task_get_data(task);
/* Convert the global ref into a local ref so that the JVM can free the stuff */
jtask_local = env->NewLocalRef(jtask_global);
env->DeleteGlobalRef(jtask_global);
- MSG_task_set_data(task, NULL);
+ MSG_task_set_data(task, nullptr);
env->ReleaseStringUTFChars(jalias, alias);
jclass comm_class;
//pointer to store the task object pointer.
msg_task_t *task = xbt_new(msg_task_t,1);
- *task = NULL;
+ *task = nullptr;
/* There should be a cache here */
comm_class = env->FindClass("org/simgrid/msg/Comm");
if (!comm_class) {
jxbt_throw_native(env,bprintf("fieldID or methodID or class not found."));
- return NULL;
+ return nullptr;
}
jobject jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor);
if (!jcomm) {
jxbt_throw_native(env,bprintf("Can't create a Comm object."));
- return NULL;
+ return nullptr;
}
mailbox = env->GetStringUTFChars(jmailbox, 0);
{
msg_error_t rv;
msg_task_t *task = xbt_new(msg_task_t,1);
- *task = NULL;
+ *task = nullptr;
- msg_host_t host = NULL;
+ msg_host_t host = nullptr;
jobject jtask_global, jtask_local;
const char *alias;
if (!host) {
jxbt_throw_notbound(env, "host", jhost);
- return NULL;
+ return nullptr;
}
}
alias = env->GetStringUTFChars(jalias, 0);
rv = MSG_task_receive_ext_bounded(task, alias, (double) jtimeout, host, (double) rate);
if (env->ExceptionOccurred())
- return NULL;
+ return nullptr;
if (rv != MSG_OK) {
jmsg_throw_status(env,rv);
- return NULL;
+ return nullptr;
}
jtask_global = (jobject) MSG_task_get_data(*task);
/* Convert the global ref into a local ref so that the JVM can free the stuff */
jtask_local = env->NewLocalRef(jtask_global);
env->DeleteGlobalRef(jtask_global);
- MSG_task_set_data(*task, NULL);
+ MSG_task_set_data(*task, nullptr);
env->ReleaseStringUTFChars(jalias, alias);
jclass comm_class;
//pointer to store the task object pointer.
msg_task_t *task = xbt_new(msg_task_t,1);
- *task = NULL;
+ *task = nullptr;
/* There should be a cac hee */
comm_class = env->FindClass("org/simgrid/msg/Comm");
if (!comm_class) {
jxbt_throw_native(env,bprintf("fieldID or methodID or class not found."));
- return NULL;
+ return nullptr;
}
jobject jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor);
if (!jcomm) {
jxbt_throw_native(env,bprintf("Can't create a Comm object."));
- return NULL;
+ return nullptr;
}
mailbox = env->GetStringUTFChars(jmailbox, 0);
comm_class = env->FindClass("org/simgrid/msg/Comm");
- if (!comm_class) return NULL;
+ if (!comm_class) return nullptr;
jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor);
mailbox = env->GetStringUTFChars(jmailbox, 0);
env->ReleaseStringUTFChars(jmailbox, mailbox);
env->DeleteLocalRef(jcomm);
jxbt_throw_notbound(env, "task", jtask);
- return NULL;
+ return nullptr;
}
MSG_task_set_data(task, (void *) env->NewGlobalRef(jtask));
comm = MSG_task_isend(task,mailbox);
env->SetLongField(jcomm, jtask_field_Comm_bind, (jlong) (uintptr_t)(comm));
- env->SetLongField(jcomm, jtask_field_Comm_taskBind, (jlong) (uintptr_t)(NULL));
+ env->SetLongField(jcomm, jtask_field_Comm_taskBind, (jlong) (uintptr_t)(nullptr));
env->SetBooleanField(jcomm, jtask_field_Comm_receiving, JNI_FALSE);
env->ReleaseStringUTFChars(jmailbox, mailbox);
comm_class = env->FindClass("org/simgrid/msg/Comm");
- if (!comm_class) return NULL;
+ if (!comm_class) return nullptr;
jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor);
mailbox = env->GetStringUTFChars(jmailbox, 0);
env->ReleaseStringUTFChars(jmailbox, mailbox);
env->DeleteLocalRef(jcomm);
jxbt_throw_notbound(env, "task", jtask);
- return NULL;
+ return nullptr;
}
MSG_task_set_data(task, (void *) env->NewGlobalRef(jtask));
comm = MSG_task_isend_bounded(task,mailbox,maxrate);
env->SetLongField(jcomm, jtask_field_Comm_bind, (jlong) (uintptr_t)(comm));
- env->SetLongField(jcomm, jtask_field_Comm_taskBind, (jlong) (uintptr_t)(NULL));
+ env->SetLongField(jcomm, jtask_field_Comm_taskBind, (jlong) (uintptr_t)(nullptr));
env->SetBooleanField(jcomm, jtask_field_Comm_receiving, JNI_FALSE);
env->ReleaseStringUTFChars(jmailbox, mailbox);
/* Destroy the global ref so that the JVM can free the stuff */
env->DeleteGlobalRef(jtask_global);
- MSG_task_set_data(task, NULL);
+ MSG_task_set_data(task, nullptr);
MSG_task_destroy(task);
}
// disk_path = (*env)->GetStringUTFChars(env, jdiskpath, 0);
// disk_path = xbt_strdup(disk_path);
- msg_vm_t vm = MSG_vm_create(host, name, (int) jncore, (int) jramsize, (int) jnetcap, NULL, (int) jdisksize,
+ msg_vm_t vm = MSG_vm_create(host, name, (int) jncore, (int) jramsize, (int) jnetcap, nullptr, (int) jdisksize,
(int) jmig_netspeed, (int) jdp_intensity);
jvm_bind(env,jvm,vm);
char *m = bprintf("Class %s not found", name);
jxbt_throw_jni(env, m);
free(m);
- return NULL;
+ return nullptr;
}
return cls;
if (!id) {
jmethodID tostr_id = env->GetMethodID(cls, "getName", "()Ljava/lang/String;");
- jstring jclassname = (jstring) env->CallObjectMethod(cls, tostr_id, NULL);
+ jstring jclassname = (jstring) env->CallObjectMethod(cls, tostr_id, nullptr);
const char *classname = env->GetStringUTFChars(jclassname, 0);
char *m = bprintf("Cannot find method %s(%s) in %s", name, signature, classname);
if (!id) {
jmethodID tostr_id = env->GetMethodID(cls, "getName", "()Ljava/lang/String;");
- jstring jclassname = (jstring) env->CallObjectMethod(cls, tostr_id, NULL);
+ jstring jclassname = (jstring) env->CallObjectMethod(cls, tostr_id, nullptr);
const char *classname = env->GetStringUTFChars(jclassname, 0);
char *m = bprintf("Cannot find static method %s(%s) in %s", name, signature, classname);
if (!id) {
jmethodID getname_id = env->GetMethodID(cls, "getName", "()Ljava/lang/String;");
- jstring jclassname = (jstring) env->CallObjectMethod(cls, getname_id, NULL);
+ jstring jclassname = (jstring) env->CallObjectMethod(cls, getname_id, nullptr);
const char *classname = env->GetStringUTFChars(jclassname, 0);
char *m = bprintf("Cannot find field %s %s in %s", signature, name, classname);
/*
* This file contains functions that aid users to debug their lua scripts; for instance,
* tables can be easily output and values are represented in a human-readable way. (For instance,
- * a NULL value becomes the string "nil").
+ * a nullptr value becomes the string "nil").
*
*/
/* SimGrid Lua debug functions */
int has_mt = lua_getmetatable(L, ud);
XBT_DEBUG("Checking the userdata: has metatable ? %d", has_mt);
- const void* actual_mt = NULL;
+ const void* actual_mt = nullptr;
if (has_mt) {
actual_mt = lua_topointer(L, -1);
lua_pop(L, 1);
XBT_DEBUG("Checking the task's metatable: expected %p, found %p", correct_mt, actual_mt);
sglua_stack_dump(L, "my_checkudata: ");
- if (p == NULL || !lua_getmetatable(L, ud) || !lua_rawequal(L, -1, -2))
- XBT_ERROR("Error: Userdata is NULL, couldn't find metatable or top of stack does not equal element below it.");
+ if (p == nullptr || !lua_getmetatable(L, ud) || !lua_rawequal(L, -1, -2))
+ XBT_ERROR("Error: Userdata is nullptr, couldn't find metatable or top of stack does not equal element below it.");
lua_pop(L, 2);
return p;
}
lua_getfield(L, index, HOST_FIELDNAME);
sg_host_t *pi = (sg_host_t *) luaL_checkudata(L, lua_gettop(L), HOST_MODULE_NAME);
lua_pop(L, 1);
- if (pi == NULL)
- XBT_ERROR("luaL_checkudata() returned NULL");
+ if (pi == nullptr)
+ XBT_ERROR("luaL_checkudata() returned nullptr");
sg_host_t ht = *pi;
if (!ht)
luaL_error(L, "null Host");
{"destroy", l_host_destroy},
// Bypass XML Methods
{"set_property", console_host_set_property},
- {NULL, NULL}
+ {nullptr, nullptr}
};
/**
{"router_new", console_add_router},
{"route_new", console_add_route},
{"ASroute_new", console_add_ASroute},
- {NULL, NULL}
+ {nullptr, nullptr}
};
int console_open(lua_State *L) {
memset(&link,0,sizeof(link));
int type;
- link.properties = NULL;
+ link.properties = nullptr;
lua_ensure(lua_istable(L, -1),"Bad Arguments to create backbone in Lua. Should be a table with named arguments.");
type = lua_gettable(L, -2);
lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER,
"Attribute 'speed' must be specified for host and must either be a string (in the correct format; check documentation) or a number.");
- host.speed_per_pstate = xbt_dynar_new(sizeof(double), NULL);
+ host.speed_per_pstate = xbt_dynar_new(sizeof(double), nullptr);
if (type == LUA_TNUMBER)
xbt_dynar_push_as(host.speed_per_pstate, double, lua_tointeger(L, -1));
else // LUA_TSTRING
}
lua_pop(L,1);
- route.gw_src = NULL;
- route.gw_dst = NULL;
+ route.gw_src = nullptr;
+ route.gw_dst = nullptr;
sg_platf_new_route(&route);
sg_host_t host = sg_host_by_name(name);
lua_ensure(host, "no host '%s' found",name);
xbt_dict_t props = sg_host_get_properties(host);
- xbt_dict_set(props,prop_id,xbt_strdup(prop_value),NULL);
+ xbt_dict_set(props,prop_id,xbt_strdup(prop_value),nullptr);
return 0;
}
{"info", info},
{"critical", critical},
{"error", error},
- {NULL, NULL}
+ {nullptr, nullptr}
};
/* ********************************************************************************* */