From: Panayotis K. <pan...@pa...> - 2010-12-16 18:37:54
|
Hello! I think I found a problem with the current implementation of XMLVM and java arrays. I am talking about this: + (XMLVMArray*) createSingleDimensionWithType:(int) type size:(int) size andData:(void*) data; In the currently implementation, data is not retained or copied anywhere. Thus, if data was automatically released at some time, the array has serious problems (and it took me a whole day to find it). The problem appears for example when NSData.bytes(); is used, where data is released back to the system. I can think of two possible solutions to this problem: 1) create a memory copy of the original data (i.e. do something similar to what clone__ does) 2) add a new member variable to XMLVMArray, which will keep hold of the creator object, and retain it (and release it when dealloc of array is found) Since this method is only used with NSData and AFAICS with initializing of multi-dimension arrays with "new" (only for their first dimension), and since NSData clearly states that this is a const structure, while with Java you can more or less do whatever you want with it, I'd suggest to fix this issue with the first solution. When we agree, I could submit a patch. What do you think? |