D
Dzikus
Hello,
Suppose I have native function
private native int sumArray(int[] arr);
How should I behave in C implementation if someone calls this function
with null value as an argument?
sumArray(null);
My first implementation was:
....(JNIEnv *env, ..., jintArray data)
{
jint *carr;
carr = (*env)->GetIntArrayElements(env, carr, 0);
if((*env)->GetArrayLength(env, carr) == 0)
{
//empty array or null?
}
....
It works on Linux but crasches on WIN
I have changed code to:
....(JNIEnv *env, ..., jintArray data)
{
jint *carr;
if(data == 0)
{
//null
}
....
It works but I'm not sure if this solution is ok. I haven't found eny
examples how to deal with such null values ...
Thanks in advance
Dominik
Suppose I have native function
private native int sumArray(int[] arr);
How should I behave in C implementation if someone calls this function
with null value as an argument?
sumArray(null);
My first implementation was:
....(JNIEnv *env, ..., jintArray data)
{
jint *carr;
carr = (*env)->GetIntArrayElements(env, carr, 0);
if((*env)->GetArrayLength(env, carr) == 0)
{
//empty array or null?
}
....
It works on Linux but crasches on WIN
I have changed code to:
....(JNIEnv *env, ..., jintArray data)
{
jint *carr;
if(data == 0)
{
//null
}
....
It works but I'm not sure if this solution is ok. I haven't found eny
examples how to deal with such null values ...
Thanks in advance
Dominik