Cannot run due to a corruption of the heap, which indicates a bug in anisotropic1.exe or any of the

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi Everyone,


I got error when I try compile my code :
Windows has triggered a breakpoint in anisotropic1.exe.<br/>
This may be due to a corruption of the heap, which indicates a bug in anisotropic1.exe or any of the DLLs it has loaded.<br/>
This may also be due to the user pressing F12 while anisotropic1.exe has focus.<br/>
The output window may have more diagnostic information.

Below is my code which got error :

SAVE properties :
int save(char path[], float *metu, int L)<br/>
{<br/>
<span style="white-space:pre FILE *fp;<br/>
<span style="white-space:pre if(!fopen_s(&fp,path,"w+") && L > 0 && metu != NULL)<br/>
<span style="white-space:pre {<br/>
<span style="white-space:pre fprintf(fp,"%f",metu[0]);<span style="white-space:pre
<----<span style="white-space:pre ERROR point to this part <br/>
<span style="white-space:pre for(int i=0;i<L;i++)<br/>
<span style="white-space:pre fprintf(fp,"%fn",metu);<br/>
<span style="white-space:pre fclose(fp);<br/>
<span style="white-space:pre return L;<br/>
<span style="white-space:pre }<br/>
<span style="white-space:pre return -1;<br/>
}

<span> Function which call save :

#include "rt_nonfinite.h"<br/>
#include "anisodiff1D.h"<br/>
#include "power.h"<br/>
#include "conv.h"<br/>
#include "load.h"<br/>
#include "save.h"<br/>
<br/>
<br/>
float *input=new float[250];<br/>
real_T bufferout[2500];<br/>
float *out=new float[1250];<br/>
real_T buffer[250];<br/>
<br/>
<br/>
<br/>
<br/>
void anisodiff1D(real_T diff_sig_data[250], int32_T diff_sig_sizes[1])<br/>
{<br/>
int L=load("pulsenoise250.txt",input);<br/>
<br/>
int32_T t;<br/>
int32_T nablaW_sizes;<br/>
real_T nablaW_data[250];<br/>
int32_T nablaE_sizes;<br/>
real_T nablaE_data[250];<br/>
real_T b_nablaW_data[250];<br/>
real_T b_nablaE_data[250];<br/>
int32_T tmp_sizes;<br/>
real_T tmp_data[250];<br/>
int iteration=5;<br/>
int kappa=2.0;<br/>
<br/>
diff_sig_sizes[0] = 250;<br/>
for (int i=0; i<250; i++)<br/>
{<br/>
diff_sig_data=input;<br/>
}<br/>
<br/>
// Anisotropic diffusion. <br/>
for (t = 0; t < iteration; t++) //loop as long as number iteration<br/>
{<br/>
<br/>
conv(diff_sig_data, diff_sig_sizes, nablaW_data, *(int32_T (*)[1])&nablaW_sizes); //do the convolution to distinguish between edge end not<br/>
<span style="white-space:pre b_conv(diff_sig_data, diff_sig_sizes, nablaE_data, *(int32_T (*)[1])&nablaE_sizes);<br/>
<span style="white-space:pre <br/>
//}<br/>
// Diffusion function. <br/>
<br/>
<br/>
nablaW_sizes = 250;<br/>
for (nablaE_sizes = 0; nablaE_sizes < 250; nablaE_sizes++) // the coefficient<br/>
<span style="white-space:pre {<br/>
b_nablaW_data[nablaE_sizes] = nablaW_data[nablaE_sizes] / kappa;<br/>
<span style="white-space:pre //printf("%fn",b_nablaW_data[nablaE_sizes]);<br/>
b_nablaE_data[nablaE_sizes] = nablaE_data[nablaE_sizes] / kappa;<br/>
}<br/>
<br/>
<span style="white-space:pre // function to get exp(-(nablaW/kappa).^2)<br/>
power(b_nablaW_data, *(int32_T (*)[1])&nablaW_sizes, tmp_data, *(int32_T (*)[1])&tmp_sizes);<br/>
power(b_nablaE_data, *(int32_T (*)[1])&nablaE_sizes, b_nablaW_data, *(int32_T (*)[1])&tmp_sizes);<br/>
<br/>
<br/>
<span style="white-space:pre // Discrete PDE solution. <br/>
<span style="white-space:pre diff_sig_sizes[0] = 250;<br/>
<span style="white-space:pre nablaE_sizes=0;<br/>
<span style="white-space:pre while(nablaE_sizes<250)<br/>
<span style="white-space:pre { <br/>
<span style="white-space:pre diff_sig_data[nablaE_sizes] = diff_sig_data[nablaE_sizes]+ (1/3) * (((1.0 / (1.0 +tmp_data[nablaE_sizes]) * nablaW_data[nablaE_sizes] + 1.0 / (1.0 +b_nablaW_data[nablaE_sizes]) * nablaE_data[nablaE_sizes]))+(input[nablaE_sizes]-diff_sig_data[nablaE_sizes]));<br/>
<span style="white-space:pre nablaE_sizes++;<br/>
<br/>
}<br/>
<span style="white-space:pre for(int a=0;a<250;a++)<br/>
<span style="white-space:pre {<br/>
<span style="white-space:pre bufferout[a]=diff_sig_data[a];<br/>
<span style="white-space:pre }<br/>
<span style="white-space:pre memcpy((void *)&out[0], (void *)&bufferout[0], 1250U * sizeof(real_T));<br/>
<span style="white-space:pre save("outputpulse250.txt",out,1250);<br/>
}<br/>
<br/>
}<br/>
<br/>


View the full article
 
Back
Top