diff --git a/cv5/program.c b/cv5/program.c index 417fc0e..de9de52 100644 --- a/cv5/program.c +++ b/cv5/program.c @@ -35,7 +35,7 @@ int main() { students_capacity = (students_capacity + 1) * 2; student_t *new_students = realloc(students, students_capacity * sizeof(student_t)); if (new_students == NULL) { - fprintf(stderr, "chyba"); + fprintf(stderr, "Error: Memory reallocation failed\n"); return 1; } students = new_students; @@ -54,9 +54,12 @@ int main() { if (strcmp(students[i].name, students[i - 1].name) != 0) { printf("%d %s\n", students[i].vote_count, students[i].name); } + } + + for (int i = 0; i < student_count; i++) { free(students[i].name); } free(students); return 0; -} \ No newline at end of file +}