Code cleanup in the List code. Possibly saved myself some headache in the future by using the right pointer type in the struct definition.

This commit is contained in:
2022-01-18 16:28:49 +00:00
parent 929f2a7f4b
commit 479dc57ea8
3 changed files with 12 additions and 23 deletions
+2 -13
View File
@@ -42,11 +42,12 @@ int main(int argc, char* args[]) {
if (i % 4 == 0) printf("Size: %d; Capacity: %d\n", list->size, list->capacity);
printf("Some Value: %d Some Text: '%s'\n", ((struct test*) list->root[list->size - 1])->SomeValue, ((struct test*) list->root[list->size - 1])->SomeText);
printf("Some Value: %d Some Text: '%s'\n", ((struct test*) list->content[list->size - 1])->SomeValue, ((struct test*) list->content[list->size - 1])->SomeText);
}
//PrintList(list);
free(thing->SomeText);
free(thing);
free(list);
}
@@ -130,16 +131,4 @@ List* get_strings(const char* line) {
}
return list;
}
void PrintList(const List* list) {
if (!list) return;
const List *current = list;
printf("Size: %d; Capacity: %d\n", list->size, list->capacity);
for(int i = 0; i < list->size; i++) {
printf("%d: %s\n", i, list->root[i]);
}
}