这就是我要做的:

static char* callerURI; //declared globally
strcpy(callerURI, reqParticipants.URI[idUser]);

哪里:
@var VidyoClientRequestParticipants::URI [out]
    Array of values for Vidyo URI of remote participants in a conference.

我是从一个SDK中得到这个的,所以不确定它是什么。
如果我记录:LOGI("VIDYO_CLIENT_OUT_EVENT_VIDEO_FRAME_RECEIVED AskViewType callerURI 1 REAL: %s" ,reqParticipants.URI[idUser]);我会得到一个字符串。
如果我这样做了:
callerURI = reqParticipants.URI[idUser];

这将起作用,并将该字符串设置为我的callerURI,但不知怎的它会被取消分配。所以我认为strcpy是正确的方法。
但尝试strcpy(callerURI, reqParticipants.URI[idUser]);会导致此错误:
06-13 05:14:08.044: E/SQLiteDatabase(1165): Error inserting value=true key=com.vidyo.vidyomod
06-13 05:14:08.044: E/SQLiteDatabase(1165): android.database.sqlite.SQLiteException: no such table: KeyValueMap (code 1): , while compiling: INSERT INTO KeyValueMap(value,key) VALUES (?,?)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at     android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1467)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1339)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at com.jb.ga0.commerce.util.io.DataBaseHelper.insert(ZeroCamera:323)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at com.jiubang.commerce.tokencoin.database.d.a(KeyValueMapTable.java:47)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at com.jiubang.commerce.tokencoin.integralwall.c$1.onAppUninstalled(AppAdsDataManager.java:101)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at com.jb.ga0.commerce.util.observer.AppChangeObserver.notifyAppUninstalled(ZeroCamera:129)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at com.jb.ga0.commerce.util.observer.AppChangeObserver.onReceive(ZeroCamera:158)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at com.jb.ga0.commerce.util.observer.AppChangeObserver.access$100(ZeroCamera:18)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at com.jb.ga0.commerce.util.observer.AppChangeObserver$AppChangedReceiver.onReceive(ZeroCamera:215)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:768)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at android.os.Handler.handleCallback(Handler.java:733)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at android.os.Handler.dispatchMessage(Handler.java:95)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at android.os.Looper.loop(Looper.java:136)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at android.app.ActivityThread.main(ActivityThread.java:5017)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at java.lang.reflect.Method.invokeNative(Native Method)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at java.lang.reflect.Method.invoke(Method.java:515)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610)
06-13 05:14:08.044: E/SQLiteDatabase(1165):     at dalvik.system.NativeStart.main(Native Method)

编辑:
我试过这个:
 LOGI("VIDYO_CLIENT_OUT_EVENT_VIDEO_FRAME_RECEIVED AskViewType callerURI 1 REAL: %s" ,reqParticipants.URI[idUser]);
char* callerTemp = reqParticipants.URI[idUser];
LOGI("VIDYO_CLIENT_OUT_EVENT_VIDEO_FRAME_RECEIVED AskViewType callerURI 12 REAL: %s" ,callerTemp);
LOGI("VIDYO_CLIENT_OUT_EVENT_VIDEO_FRAME_RECEIVED AskViewType callerURI 13 REAL: %s" ,strlen(callerTemp));
*callerURI= (char *) malloc(sizeof(char *) * (strlen(callerTemp) + 1 ));
strcpy(callerURI, reqParticipants.URI[idUser]);
LOGI("VIDYO_CLIENT_OUT_EVENT_VIDEO_FRAME_RECEIVED AskViewType callerURI 2 REAL: %s" ,reqParticipants.URI[idUser]);
LOGI("VIDYO_CLIENT_OUT_EVENT_VIDEO_FRAME_RECEIVED AskViewType callerURI 2 : %s" ,callerURI);

但我只记录了这个:
06-13 05:40:27.294: I/VidyoMobile app/src/main/jni/ndkVidyoSample.c(19744): VIDYO_CLIENT_OUT_EVENT_VIDEO_FRAME_RECEIVED AskViewType callerURI 1 REAL: scip:CsAPI1528869039-4c6-42722300022166be-d30ff886a73e0ebc;transport=TLS
06-13 05:40:27.294: I/VidyoMobile app/src/main/jni/ndkVidyoSample.c(19744): VIDYO_CLIENT_OUT_EVENT_VIDEO_FRAME_RECEIVED AskViewType callerURI 12 REAL: scip:CsAPI1528869039-4c6-42722300022166be-d30ff886a73e0ebc;transport=TLS

所以strlen()也会因为某种原因崩溃。这是为什么?

最佳答案

static char* callerURI;

你没有在这里分配内存,所以callerURI只是一个门垫,不是你可以进入的房子。
在调用strcpy之前,必须为callerURI分配内存。也许您可以使用reqParticipants.URI[idUser]来找出需要分配的内存。

09-28 05:13