So I initialize my array like this:
struct LevelPoint list[30];
This is LevelPoint:
typedef struct LevelPoint {
Material ground_material;
int ground_height;
} LevelPoint;
I have another list points:
LevelPoint **points;
I then use a for loop to add items to points:
for(int j =0;j<level->width;j++){
for(int i = 0;i< level->height;i++){
//bitsOmzetter return a value from 0-3
k = bitsOmzetter(&l,ptr,&w);
if(k == 3){
if(i==0){
list[i] = level->points[j-1][level->height-1];
}else{
list[i] = list[i-1];
}
}else{
//level ->points[j] ->ground_material = k;
//level -> points[j] ->ground_height = bitsOmzetter(&j,ptr,&w)+1;
LevelPoint point;
point.ground_material = k;
point.ground_height = bitsOmzetter(&l,ptr,&w)+1;;
list[i] = point;
//list[j][i] -> ground_material = k;
//list[j][i] -> ground_height = bitsOmzetter(&j,ptr,&w)+1;
}
}
level->points[j] = list;
}
but this always gives me an error of:
==12788==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x559c5edaa671 bp 0x7ffda2a59db0 sp 0x7ffda2a57ce0 T0)
==12788==The signal is caused by a WRITE memory access.
==12788==Hint: address points to the zero page.
#0 0x559c5edaa671 in levelloader_load_binary_level /home/student/Desktop/Systeemprogrammeren2022-project-groep-22/game/level/c_levelloader.c:66
line 66 is level->points[j] = list;
. I tried debugging but that shows that my list is empty : list[0] is all it shows.
I tried initialzing the array in other ways but it always failed.