diff --git a/include/gallery_p/gallery.h b/include/gallery_p/gallery.h index 3507344..73404b6 100644 --- a/include/gallery_p/gallery.h +++ b/include/gallery_p/gallery.h @@ -22,7 +22,9 @@ typedef struct album_s gallery_t *get_album_list(); gallery_t *new_album_item(char *title); +void free_albums_list(gallery_t *albums_list); img_t new_img_item(char *path); +void free_img_item(img_t img); int get_album_imgs(img_t **images_arr, int *size, char *title); char *gen_gallery_html(); diff --git a/src/gallery_p/gallery.c b/src/gallery_p/gallery.c index a34eae6..efda5db 100644 --- a/src/gallery_p/gallery.c +++ b/src/gallery_p/gallery.c @@ -43,6 +43,27 @@ gallery_t *get_album_list() return list; } +/** + * @brief Free gallery_t structure + * + * @return void + */ +void free_albums_list(gallery_t *albums_list) +{ + gallery_t *curr_item = albums_list; + + while (curr_item != NULL) + { + free(curr_item->title); + for (int i = 0; i < curr_item->img_am; i++) + free_img_item(curr_item->images[i]); + free(curr_item->images); + curr_item = curr_item->next; + } + + free(albums_list); +} + /** * @brief Generates new album item * @@ -86,6 +107,18 @@ img_t new_img_item(char *path) return img; } +/** + * @brief Free img_t structure + * + * @return void + */ +void free_img_item(img_t img) +{ + free(img.description); + free(img.path); + free(img.tags); +} + int get_album_imgs(img_t **images_arr, int *size, char *title) { char **photos_list = calloc(0, sizeof(char *)); @@ -135,7 +168,8 @@ char *gen_gallery_html() fread(image_template, image_file_size, 1, image_template_fp); fclose(image_template_fp); - gallery_t *albums_list_item = get_album_list(); + gallery_t *albums_list = get_album_list(); + gallery_t *albums_list_item = albums_list; char *gallery_content = strdup(""); @@ -190,7 +224,7 @@ char *gen_gallery_html() } free(album_template); - free(image_template); + free_albums_list(albums_list); return gallery_content; } \ No newline at end of file diff --git a/static/gallery/albums/Moscow_and_Saint_Petersburg/B0B7TV3H-A3.jpg b/static/gallery/albums/Moscow_and_Saint_Petersburg/B0B7TV3H-A3.jpg new file mode 100644 index 0000000..b53b370 Binary files /dev/null and b/static/gallery/albums/Moscow_and_Saint_Petersburg/B0B7TV3H-A3.jpg differ diff --git a/static/gallery/albums/Moscow_and_Saint_Petersburg/B0Gg7f0HrJt.jpg b/static/gallery/albums/Moscow_and_Saint_Petersburg/B0Gg7f0HrJt.jpg new file mode 100644 index 0000000..25ff2bc Binary files /dev/null and b/static/gallery/albums/Moscow_and_Saint_Petersburg/B0Gg7f0HrJt.jpg differ diff --git a/static/gallery/albums/Moscow_and_Saint_Petersburg/B0LQnzWn8ar.jpg b/static/gallery/albums/Moscow_and_Saint_Petersburg/B0LQnzWn8ar.jpg new file mode 100644 index 0000000..5598f0f Binary files /dev/null and b/static/gallery/albums/Moscow_and_Saint_Petersburg/B0LQnzWn8ar.jpg differ diff --git a/static/gallery/albums/Moscow_and_Saint_Petersburg/B0S5VLanPi8.jpg b/static/gallery/albums/Moscow_and_Saint_Petersburg/B0S5VLanPi8.jpg new file mode 100644 index 0000000..ff0b30b Binary files /dev/null and b/static/gallery/albums/Moscow_and_Saint_Petersburg/B0S5VLanPi8.jpg differ diff --git a/static/gallery/albums/Moscow_and_Saint_Petersburg/B0V4ZMhnREF.jpg b/static/gallery/albums/Moscow_and_Saint_Petersburg/B0V4ZMhnREF.jpg new file mode 100644 index 0000000..4acd327 Binary files /dev/null and b/static/gallery/albums/Moscow_and_Saint_Petersburg/B0V4ZMhnREF.jpg differ diff --git a/static/gallery/albums/Moscow_and_Saint_Petersburg/Bz8uWdtHUh5.jpg b/static/gallery/albums/Moscow_and_Saint_Petersburg/Bz8uWdtHUh5.jpg new file mode 100644 index 0000000..4b88114 Binary files /dev/null and b/static/gallery/albums/Moscow_and_Saint_Petersburg/Bz8uWdtHUh5.jpg differ