Compare commits

...

2 commits

3 changed files with 9 additions and 1 deletions

View file

@ -25,6 +25,7 @@
#define FLEDASTY_LINKED_LIST
#include <stddef.h>
#include <stdbool.h>
#include "../Utils/Error.h"
@ -43,4 +44,6 @@ FledastyError fledasty_linked_list_destroy(FledastyLinkedList *current_linked_li
FledastyError fledasty_linked_list_append(FledastyLinkedList *current_linked_list, void *value);
static inline bool fledasty_linked_list_is_empty(FledastyLinkedList *current_linked_list) { return current_linked_list->size == 0; }
#endif

View file

@ -99,6 +99,7 @@ FledastyError fledasty_linked_list_append(FledastyLinkedList *current_linked_lis
new_node->next = NULL;
current_linked_list->end->next = new_node;
current_linked_list->end = new_node;
current_linked_list->size += 1;
return FLEDASTY_ERROR_NONE;

View file

@ -111,11 +111,15 @@ int main() {
}
FledastyLinkedListNode *test_linked_list_node = test_linked_list.start;
for (int i = 0; i < test_linked_list.size; i++) {
for (int i = 0; i < test_linked_list.size; i += 1) {
printf("Linked list get: %d\n", *(int*)test_linked_list_node->value);
test_linked_list_node = test_linked_list_node->next;
}
if (fledasty_linked_list_is_empty(&test_linked_list)) {
printf("Linked list is empty\n");
}
fledasty_linked_list_destroy(&test_linked_list);
printf("Done\n");
return 0;