[PATCH v2 02/10] vbscript: Reference count the persistent code list.

Gabriel Ivăncescu gabrielopcode at gmail.com
Thu Nov 14 06:50:40 CST 2019


On 11/13/19 11:53 PM, Jacek Caban wrote:
> Hi Gabriel,
> 
> On 11/13/19 4:24 PM, Gabriel Ivăncescu wrote:
>> Signed-off-by: Gabriel Ivăncescu<gabrielopcode at gmail.com>
>> ---
>>
>> This is needed for the TypeInfo since it needs to hold a ref to the
>> persistent code, too. Though we keep the ref in the script dispatch since
>> it's more correct this way (even though we bail out when there's no 
>> context,
>> we still technically reference the persistent code funcs/classes in the
>> dispatch object).
>>
>> I couldn't refcount the script context itself since it is re-used 
>> after being
>> closed, and was not deemed a good approach to free it (my previous 
>> attempts).
> 
> 
> It doesn't look pretty, but also I think it's not enough for what you 
> need. What about non-persistent code? Unless I'm missing something, this 
> will be exposed from ITypeInfo as well, but freed when script is 
> uninitialized, so we will crash on an attempt to access it. An 
> alternative idea would be to add a reference count to vbscode_t itself. 
> It could be referenced by each entry in global variables and functions 
> arrays as well as from ITypeInfo implementation. How does that sound?
> 
> 
> Thanks,
> 
> Jacek
> 

The non-persistent code gets moved to the script dispatch when it is 
released, so it shouldn't be an issue, because the TypeInfo keeps a 
reference to it, so the script dispatch itself won't be freed when the 
script gets released in this particular case.

Refcounting the vbscode itself is possible but I think it will be more 
complicated though. We'll also have to loop through all 
variables/functions to add a ref to them when creating the TypeInfo 
(currently we don't even store the vars list at all since we read it 
directly from the script dispatch).

I think this is the simplest approach, still. (ref counting the 
persistent code list)

Thanks,
Gabriel



More information about the wine-devel mailing list