Reputation: 25
I am using Xcode to code in C language. I am getting strange error.
If ranges(height2, width2
) of for loops are around 500,600 code is working fine. BUT if I change ranges more than 800 then it gives me following error.
"Thread 1: EXE_BAD_ACCESS(CODE - 2, address = 07x33434...)"
for (int i = 0 ; i <height2 ; i++)
{
for (int j = 0 ; j< width2 ; j++)
{
float height_Frac_Idx = i*scale_h;
float width_Frac_Idx = j*scale_w;
int height_idx, width_idx;
height_idx = (int) height_Frac_Idx;
width_idx = (int) width_Frac_Idx;
float del_h = height_Frac_Idx - height_idx;
float del_w = width_Frac_Idx - width_idx;
img_op[i][j] = (img_IP[height_idx][width_idx])*(1 - del_h)*(1-del_w) + (img_IP[height_idx+1][width_idx])*(del_h)*(1-del_w) + (img_IP[height_idx][width_idx+1])*(1 - del_h)*(del_w) + (img_IP[height_idx+1][width_idx+1])*(del_h)*(del_w);
}
}
Upvotes: 1
Views: 137
Reputation: 1901
"Thread 1: EXE_BAD_ACCESS(CODE - 2, address = 07x33434...)"
This error come when when you accessing the unallocated or more that allocated memory in code.
Looking your code and explanation i can guess that you probably accessing some more memory in case of img_op[][] or img_IP[][]
array.
Also try Enabling NSZombies Very easy to enable:
Double click your executable in the “Executables” in XCode
Open “Arguments” tab
Upvotes: 1