<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Now I realize that everything I posted in the last post makes
absolutely no sense at all. Something else is causing the crashes.
Damn!<br>
</p>
<br>
<div class="moz-cite-prefix">On 6/8/17 10:51 AM, David Medine wrote:<br>
</div>
<blockquote type="cite"
cite="mid:a55e31d0-47e5-0c2f-dbca-d412b8225dda@ucsd.edu">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<p>I am writing a DSP extern that can have a any number of outlets
depending on the creation arguments (like [fexpr~], e.g.). In
order to interact with the outlets in the <tt>XXX_tilde_perform</tt>
loop, I made a member of my <tt>t_XXX_tilde</tt> data structure
thus:</p>
<p><tt>t_sample **lcl_outs;</tt></p>
<p>Then, when I know how many outlets I need, I allocate the
appropriate amount of memory. In the<tt> XXX_tilde_perform</tt>
loop, I set the pointers to those handed by Pd's scheduling
engine in the standard way:</p>
<p><tt>for(int i=0;i<x->nouts;i++)</tt></p>
<p><tt> x->lcl_outs[i] = w[2+i];</tt></p>
<p>I found that this would sporadically crash Pd when turning the
DSP engine on and off and (sometimes) when
connecting/disconnecting to one of the outlets. I think that I
have solved this problem by copying my pointers at the head of
the <tt>XXX_tilde_perform</tt> method to a local variable:</p>
<p><tt>t_sample **lcl_outs = x->lcl_outs;</tt></p>
<p><tt>for(int i=0;i<x->nouts;i++)</tt></p>
<tt> </tt>
<p><tt> lcl_outs[i] = w[2+i];</tt></p>
<p>Everything <i>appears</i> to work now. I assume that somehow
Pd's engine is rubbing my <tt>x->lcl_outs</tt> ptr off of
the stack. Thus, by copying it to another ptr I avoid this
problem because my OS still knows where the allocated memory is.
That is to say, when Pd gets rid of whatever<tt> w[2] </tt>is,
it then removes the ptr <tt>lcl_outs</tt>, not <tt>x->lcl_outs</tt>,
which still has memory behind it.<br>
</p>
<p>Am I reading this right? I am not at all confident that I have
truly solved this problem. If anyone has any insight, I'd like
to know too.<br>
</p>
<p>Thanks!</p>
<p>David<br>
</p>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
<a class="moz-txt-link-abbreviated" href="mailto:Pd-list@lists.iem.at">Pd-list@lists.iem.at</a> mailing list
UNSUBSCRIBE and account-management -> <a class="moz-txt-link-freetext" href="https://lists.puredata.info/listinfo/pd-list">https://lists.puredata.info/listinfo/pd-list</a>
</pre>
</blockquote>
<br>
</body>
</html>