aboutsummaryrefslogtreecommitdiff
path: root/src/components.c
diff options
context:
space:
mode:
authorYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-11-08 23:29:08 +0300
committerYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-11-08 23:29:08 +0300
commitabbee959bf5c87a8b2ad0b2d55d9ddb955147892 (patch)
treed1d9f09c7a650499c282d4642faa06ac171abd29 /src/components.c
parentaf5ac2e6df9c3a9c0c7c5bd35125b81a69b68069 (diff)
downloadrevela-abbee959bf5c87a8b2ad0b2d55d9ddb955147892.tar.gz
revela-abbee959bf5c87a8b2ad0b2d55d9ddb955147892.zip
Minor fixes here and there
* Added year variable to album template * Fixed a minor leak and dangling pointer * Other small improvements
Diffstat (limited to 'src/components.c')
-rw-r--r--src/components.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/components.c b/src/components.c
index 082eab9..8937a83 100644
--- a/src/components.c
+++ b/src/components.c
@@ -199,7 +199,7 @@ album_new(struct album_config *conf, struct site_config *sconf, const char *src,
album->slug = slugify(rsrc, sconf->base_url, &album->url);
album->images = bstree_new(image_cmp, image_destroy);
album->tstamp = MAXTIME;
- album->map = hashmap_new_with_cap(8);
+ album->map = hashmap_new_with_cap(16);
album->thumbs = vector_new(128);
album->previews = vector_new(sconf->max_previews);
@@ -223,6 +223,15 @@ album_add_image(struct album *album, struct image *image)
}
void
+album_set_year(struct album *album)
+{
+ char *delim = strchr(album->datestr, '-');
+ size_t n = delim - album->datestr;
+ strncpy(album->year, album->datestr, n);
+ album->year[n] = '\0';
+}
+
+void
album_destroy(void *data)
{
struct album *album = data;