Note that there are some explanatory texts on larger screens.

plurals
  1. POPointer in struct question. Have I done it correct?
    primarykey
    data
    text
    <p>I am rewriting some code from having a regular pointer to where the pointer is in a struct.</p> <p>This is the original code which works:</p> <pre><code>int wrote = sf_writef_double(outfile, *mono_channel, frames); </code></pre> <p>In the new code, where I have put the mono_channel pointer in a struct have I written</p> <pre><code>int wrote = sf_writef_double(outfile, data-&gt;mono_channel, frames); </code></pre> <p>The compiler doesn't complain, but the program crashes.</p> <p>So the question is. Is <code>data-&gt;mono_channel</code> the same as <code>*mono_channel</code>?</p> <p>Hugs, Louise</p> <p><strong>Edit:</strong> To be more precise here is what I do:</p> <pre><code>ltfat_complex* fm; fm = malloc(data-&gt;L * sizeof(ltfat_complex)); if (fm == NULL) { puts("fm malloc failed"); exit(1); } /* Writes output to fm */ idgt_fac(data-&gt;coef, gdf, data-&gt;L, 1, 1, data-&gt;a, data-&gt;M, fm); free(data-&gt;mono_channel); data-&gt;mono_channel = (double*) fm; free(fm); </code></pre> <p>...</p> <pre><code>int wrote = sf_writef_double(outfile_handler, data-&gt;mono_channel, frames); </code></pre> <p>Could the problem be, that I try to re-use the <code>data-&gt;mono_channel</code> pointer?</p> <p><strong>Edit2:</strong> Here are the entire source codes (~ 700 lines each):</p> <p>Old which works: <a href="http://www.student.dtu.dk/~s011392/gabor-io.zip" rel="nofollow noreferrer">http://www.student.dtu.dk/~s011392/gabor-io.zip</a></p> <p>New: <a href="http://www.student.dtu.dk/~s011392/gui.zip" rel="nofollow noreferrer">http://www.student.dtu.dk/~s011392/gui.zip</a></p> <p>Sadly they require a lot of libraries to compile: ltfat from SVN, fftw3, lapack, blas, sndfile.</p> <p>But there tey are =)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload