<div dir="ltr">Michael,<div><br></div><div>Thanks. Just to clarify, I wrote Multiverb as a class that inherits from the plugin template in lv2-c++-tools. Multiverb uses another class called DelayLine, which has its own ctor and dtor. The private variables of Multiverb include two fixed-length arrays of DelayLine objects. As I understand C++, these objects are implicitly instantiated and destroyed when, respectively, Multiverb is instantiated and destroyed. The DelayLine create method (not the ctor), which is called by the Multiverb ctor, allocates the float array with a new command. The DelayLine dtor frees this array. SO - I do believe that all allocation occurs during Multiverb instantiation and all freeing occurs during Multiverb destruction, as it should!</div>
<div><br></div><div>Warren</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Dec 28, 2013 at 1:20 PM, Michael R. Fisher <span dir="ltr"><<a href="mailto:mfisher31@gmail.com" target="_blank">mfisher31@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>With lv2-c++-tools, the ctor and dtor of your plugin match up with 'instantiate' and 'cleanup' respectively.  </div>
<div><div class="h5"><div><br><br><div><br></div></div><div><br>On Dec 27, 2013, at 8:23 AM, Warren Koontz <<a href="mailto:profwub@gmail.com" target="_blank">profwub@gmail.com</a>> wrote:<br><br></div><blockquote type="cite">
<div><div dir="ltr">My plugin uses an array of buffers with different lengths. I am considering options for implementation:<div><br></div><div>Programming 101 option:<br></div><div><br></div><div><font face="courier new, monospace">#define ORDER 8 // number of buffers</font></div>

<div><font face="courier new, monospace">#define MAXLEN 5000 // length of largest buffer</font></div><div><font face="courier new, monospace">float buffer[ORDER][MAXLEN];</font></div><div><font face="courier new, monospace">unsigned ptr[ORDER];</font></div>

<div><font face="courier new, monospace"><br></font></div><div>Programming 201 option:<br></div><div><br></div><div><font face="courier new, monospace">#define ORDER 8</font></div><div><font face="courier new, monospace">struct Buffer {</font></div>

<div><font face="courier new, monospace">    float *buf;</font></div><div><font face="courier new, monospace">    unsigned ptr;</font></div><div><font face="courier new, monospace">} buffer[ORDER];</font></div><div><font face="courier new, monospace">unsigned size[] = {/* list of buffer lengths */};</font></div>

<div><font face="courier new, monospace">for (unsigned i = 0; i < ORDER; i++)</font></div><div><font face="courier new, monospace">    buffer[i].buf = new float[size[i]];</font></div><div><font face="courier new, monospace"><br>

</font></div><div>Programming 301 option:</div><div><br></div><div><font face="courier new, monospace">class Buffer </font><font face="arial, helvetica, sans-serif">etc.</font></div><div><font face="arial, helvetica, sans-serif"><br>

</font></div><div><font face="arial, helvetica, sans-serif">The latter two options require dynamic allocation and freeing. Can this be safely done in </font><font face="courier new, monospace">activate</font><font face="arial, helvetica, sans-serif"> and </font><font face="courier new, monospace">deactivate</font><font face="arial, helvetica, sans-serif">? I could also do the allocation in the constructor for my plugin but, since I am using lv2-c++-tools and inheriting from the </font><font face="courier new, monospace">plugin</font><font face="arial, helvetica, sans-serif"> class, I am not sure where I can do the freeing. I hate to go with the 101 option - looks too much like my MATLAB implementation. But if it is the safest way ...</font></div>

<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Thanks again.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Warren</font></div>

</div>
</div></blockquote></div></div><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Devel mailing list</span><br><span><a href="mailto:Devel@lists.lv2plug.in" target="_blank">Devel@lists.lv2plug.in</a></span><br>
<span><a href="http://lists.lv2plug.in/listinfo.cgi/devel-lv2plug.in" target="_blank">http://lists.lv2plug.in/listinfo.cgi/devel-lv2plug.in</a></span><br></div></blockquote></div></blockquote></div><br></div>