Program nie chce mi nic zapisać do komórki fun->def w ostatniej funkcji
Gdy próbowałem podejrzeć ja w debugerze wyświela mi komunikat error: Cannot access memory at address 0x8
ale nie wiem dla czego. Mógł by mi ktoś to wytłumaczyć ?
static scont * tab[1000];
static int amont = 0;
static scont* ws = NULL;
static char* temp = NULL;
scont* spr(char * name){
int i;
for ( i = 0; i < amont; i++){
if (!strcmp(name,tab[i]->name))
return tab[i]; }
scont * t = malloc( sizeof * t);
t->name = strdup(name);
t->def = NULL;
t->prot = NULL;
t->call = NULL;
t->wywoluje = NULL;
tab[i] = t;
amont++;
return tab[i];
}
void add(char * gdzie, char* co){
if (gdzie == NULL){
gdzie = strdup(co);
return;}
gdzie = realloc(gdzie, strlen(gdzie) + strlen(co) + 1);
gdzie = strcat(gdzie,co);
}
char* wiersz( char* nazwaPliku, int numerLini){
char tmp[500];
int n;
n = sprintf(tmp, "plik: %s od lini %d \n", nazwaPliku, numerLini);
temp = realloc(temp,n+1);
strcpy(temp,tmp);
return temp;
}
void store_add_def (char* funkcja, int numerLini, char* nazwaPliku)
{
scont * fun = spr(funkcja);
add(fun->def, wiersz(nazwaPliku, numerLini);
ws = fun;
}