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:
+2
-13
@@ -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]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user