Android SIGSEGV错误与数组

时间:2015-09-23 18:18:16

标签: android pointers java-native-interface sigsegv native-code

我在Android中使用本机代码时遇到了问题。

我使用此代码使用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;
}

我使用此代码创建指针并从函数中获取值:

float *x = Map.ConvertToArray();

它在Windows中工作,但在android中我有问题..

祝你好运

1 个答案:

答案 0 :(得分:0)

我明白了!

答案代码必须如下:

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

谢谢大家;)