From: Arno P. <ar...@pu...> - 2010-12-17 00:19:48
|
I agree in principle with your proposed first solution. However, there are also instances where it is not necessary to copy the array (e.g., the dex:fill-array instruction). I would suggest to add another boolean parameter to that method that states if 'data' should be copied or not and then go through the code and decide individually where the data needs to be copied or not. If we can avoid unnecessary copying, we should. Arno On 12/16/10 10:37 AM, Panayotis Katsaloulis wrote: > 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? > > > ------------------------------------------------------------------------------ > Lotusphere 2011 > Register now for Lotusphere 2011 and learn how > to connect the dots, take your collaborative environment > to the next level, and enter the era of Social Business. > http://p.sf.net/sfu/lotusphere-d2d > _______________________________________________ > xmlvm-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlvm-users |