And my changes in code :
Code:
row *create_row(int values[], char tab_name[]) {
printf("2.1\n");
if (find_tab(tab_name)->first_row != NULL) {
print_row(find_tab(tab_name),find_tab(tab_name)->first_row);
}
tab *tab_temp = find_tab(tab_name);
printf("2.2\n");
row *actual = malloc(sizeof(row));
item *first_item;
printf("2.3\n");
item *last_added = NULL;
int i;
if (tab_temp->first_row != NULL) print_row(tab_temp,tab_temp->first_row);
printf("2.4\n");
for (i = 0; i < tab_temp->columns_count; i++) {
item *iter = malloc(sizeof(item));
iter->value = values[i];
iter->next = NULL;
if (last_added) {
last_added->next = iter;
}
else {
first_item = iter;
}
last_added = iter;
printf("Value %d\n",iter->value);
}
if (tab_temp->first_row != NULL) print_row(tab_temp,tab_temp->first_row);
printf("2.5\n");
actual->first_item = first_item;
actual->next = NULL;
printf("2.6\n");
if (tab_temp->first_row != NULL) print_row(tab_temp,tab_temp->first_row);
if (tab_temp->first_row == NULL) {
tab_temp->first_row = actual;
}
else {
actual->next = tab_temp->first_row;
tab_temp->first_row = actual;
}
if (tab_temp->first_row != NULL) print_row(tab_temp,tab_temp->first_row);
printf("2.7\n");
print_row(tab_temp,tab_temp->first_row);
printf("2.8\n");
return actual;
}