Log in

View Full Version : [REQ] Reference counted arrays in AVSValue


mg262
19th November 2005, 13:24
The current code:AVSValue(const AVSValue* a, int size)
{ type = 'a'; array = a; array_size = size; }leaves plug-ins to allocate memory for arrays inside AVSValue. Plug-ins have no way of knowing when they can deallocate this memory, so AFAIK a memory leak occurs. This is a shame, because AVSValue arrays provide the cleanest mechanism for returning multiple clips or returning auxiliary information with clips.

Would you consider one of the following?

1. Reference counted arrays inside AVSValue
AVSValue(const smart_ptr<AVSValue> a, int size)
{ type = 'A'; smart_p = a; array_size = size; }
2. Copy-by-value arrays inside AVSValue
AVSValue(const vector<AVSValue> a)
{ type = 'A'; v = a; }
(Or one of these as a replacement for the existing mechanism if you don't think it would break inaccessible code.)

vcmohan
20th November 2005, 04:15
AVSValue arrays provide the cleanest mechanism for returning multiple clips
Is it possible for a plugin to return multiple clips? I thought this is not possible.

mg262
20th November 2005, 10:14
A plug-in returns an AVSValue -- any AVSValue. This can be a clip, a string, an integer or even an array of AVSValues. So you can return an array of clips. (You want to be careful though, because you could mess up the cache if you simply construct your IClips directly... I think there is a way to get the cached clips via Invoke.)