diff --git a/src/lst/lst.h b/src/lst/lst.h index d14f38a..ec5c4d2 100644 --- a/src/lst/lst.h +++ b/src/lst/lst.h @@ -1,5 +1,6 @@ #pragma once #include +#include typedef struct s_lst { diff --git a/src/lst/lst_clear.c b/src/lst/lst_clear.c new file mode 100644 index 0000000..423ea4b --- /dev/null +++ b/src/lst/lst_clear.c @@ -0,0 +1,16 @@ +#include "./lst.h" + +void lst_clear(lst **root, void (*del)(void *)) +{ + lst* current = *root; + lst* next; + + while (current != NULL) + { + next = current->next; + (*del)(current->content); + free(current); + current = next; + } + free(root); +} diff --git a/src/lst/lst_iter.c b/src/lst/lst_iter.c index fb8210c..95ce94b 100644 --- a/src/lst/lst_iter.c +++ b/src/lst/lst_iter.c @@ -6,7 +6,7 @@ void lst_iter(lst** root, void (*f)(void *)) while (current != NULL) { - (*f)(current); + (*f)(current->content); current = current->next; } } diff --git a/src/str/str_shift.c b/src/str/str_shift.c index d735746..781bb23 100644 --- a/src/str/str_shift.c +++ b/src/str/str_shift.c @@ -2,8 +2,10 @@ void str_shift(char *str, int shift) { - for (size_t i = 0; str[i] == '\0'; i++) + size_t i = 0; + while (str[i - shift - 1] != '\0') { - + str[i] = str[i - shift]; + i++; } }