English 中文(简体)
2个土著单元(Android NDK)之间的通过数据
原标题:Pass data between 2 native modules (Android NDK)

Here is the structure of my program: - 2 independent modules libA and libB, each one is a single shared library libA.so and libB.so - A java activity creating 2 threads thA and thB, each one of them calling native JNI functions from one library (thA calling functions from libA.so and thB calling function from libB.so).

我想通过两个图书馆之间的土著类型数据( Java不了解任何情况,如Java能够操作的线人),但我无法找到任何途径来进行交流。

两个图书馆都知道土著类型“类型A”的定义,因此可以通过一种类型的物体。 A from libA to libB(最好不必在考试和测验记忆中复制数据)。 可以通过一个记忆点?

增 编

问题回答

我在一份申请中就这样做了。 我在校正中分配记忆,并将点击器作为<条码>长期,直至通过国家情报机构报到。 然后,我打电话给B校一个功能,穿透点,以便能够进入。

However, this naive approach has problems. Although it may work sometimes, if libA and libB live on different pages of RAM, touching the pointer in libB may crash the program. The reason reported for the crash may vary on the build and run, making it a difficult situation to debug. Even worse, if the memory allocated partially resides on one page of RAM and partially on another, only when you hit the boundary you will crash whatever lies beyond, and therefore may not detect the problem immediately. I have managed to kill the OS numerous times and produce any number of various errors. If your libraries are small and loaded in adjacent memory, odds are good you will be okay. Native applications on Android can get away with things that vanilla Java apps cannot.

<>Solutions:

  1. Ashmem将允许你在申请之间建立共享记忆空间。 如果你是新到的安康发展公司或欧兰诺维索公司,这可能会在学习曲线上出现。

  2. You could use a Socket between two applications and stream the data.

  3. 可以通过,该功能必须大小,以适应平衡A的数据。 届时,你可以再次通过民族阵线将其降为平衡。 这种解决办法将较为缓慢,其代价可能会使你开始使用本地法典的理由失去效力,但如果你的问题与你的方案逻辑有关或必然存在,那么,这样做会为欺骗和发现提供一个良好途径。

Passing a pointer to a typeA from A to B may be an option. It depends on the live cycle of typeA in the libraries though. Make sure that the typeA object is not deleted in one library while it s still in use in the other.

一条通过点子的途径是超越国家情报和安全局,用一个长/长的间隔代表点。





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签