EDIT: SOLVED PROBLEM THANKS ANYWAY
I keep getting a seg_fault .. I am certain it has to do with my setting 'processed_pixels' array to some value ..
heres the gdb debug entry
Ive commented out some code and simplified to help me find the error but I can't quite find it.Code:Program received signal SIGSEGV, Segmentation fault.
0x08048cbd in set_bg_processed (png_rows=0x8051000, processed_pixels=0x1)
at splicer.c:95
95 processed_pixels[i][pixel_j] = 1;
Code:char **processed_pixels = malloc(img_height * sizeof(char*));
int i;
for(i=0;i<img_height;++i)
processed_pixels[i] = calloc(stride, 1);
set_bg_processed(png_rows);
i am new to C :(Code:void set_bg_processed(png_bytepp png_rows, char **processed_pixels)
{
int i,j;
for(i=0;i<img_height;++i)
{
for(j=0;j<stride;j+=channels)
{
if( 1 ) //condition code elided, still seg_faults
{
int pixel_j = j / channels;
printf("debug: setting %d %d to processed ... \n ",i, pixel_j);
assert( pixel_j >= 0); // asserting pixel_j so it can be shown that it is positive here on the forum wihout showing 'channels' code
processed_pixels[i][pixel_j] = 1;
printf("\tdone\n");
}
}
}
}
I think it crashes on i=0, pixel_j = 0
Thanks for helping!