Search code examples
androidpointersjava-native-interfacesegmentation-faultnative-code

Android SIGSEGV error with array


I've problem with native code in Android.

I used this code to fill array with content from vector

float * Map_Loader::ConvertToArray()
{
    float *arr = new float[(faces.size() -1)*3];
    int index = 0, j = 0;
    while(index < faces.size())
    {
        arr[ j ] = faces[ index ].vertex[ 0 ].x;
        arr[ j +1 ] = faces[ index ].vertex[ 1 ].y;
        arr[ j +2 ] = faces[ index ].vertex[ 2 ].z;
        j += 3;
        index++;
    }
    return arr;
}

and I used this code to create pointer and get values from the function:

float *x = Map.ConvertToArray();

It's working in windows , but in android I've problem..

Best regards


Solution

  • I get it !!

    The answer code must be like this :

    float *x;
    x = Map.ConvertToArray();
    

    thanks everybody ;)