From 75906fbb296d2ed7cd9ca05e1b7bf0c92f84a30b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Thu, 24 Mar 2022 01:09:48 +0300 Subject: Switch from unja to roscha Still a WIP, some bugs need to be fixed. Also change the license to GPL from LGPL. It was always meant to be GPL, not sure what brain fart caused this. --- src/fs.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/fs.c') diff --git a/src/fs.c b/src/fs.c index 49d6e0d..b6ec372 100644 --- a/src/fs.c +++ b/src/fs.c @@ -2,7 +2,9 @@ #include "log.h" #include "config.h" + #include "vector.h" +#include "slice.h" #include #include @@ -37,7 +39,7 @@ static const char *img_extensions[] = { }; static void -hm_destroy_callback(const void *k, void *v) +hm_destroy_cb(const struct slice *k, void *v) { free(v); } @@ -199,7 +201,7 @@ error: } ssize_t -rmextra(const char *path, struct hashmap *preserved, preremove_fn cb, +rmextra(const char *path, struct hmap *preserved, preremove_fn cb, void *data, bool dry) { ssize_t removed = 0; @@ -212,7 +214,7 @@ rmextra(const char *path, struct hashmap *preserved, preremove_fn cb, continue; } - if (hashmap_get(preserved, ent->d_name) != NULL) continue; + if (hmap_get(preserved, ent->d_name) != NULL) continue; char target[PATH_MAX]; sprintf(target, "%s/%s", path, ent->d_name); @@ -232,7 +234,7 @@ rmextra(const char *path, struct hashmap *preserved, preremove_fn cb, bool filesync(const char *restrict srcpath, const char *restrict dstpath, - struct hashmap *preserved, bool dry) + struct hmap *preserved, bool dry) { int fdsrc; struct stat stsrc; @@ -271,9 +273,9 @@ filesync(const char *restrict srcpath, const char *restrict dstpath, if (cleanup) { if (preserved == NULL) { - preserved = hashmap_new(); + preserved = hmap_new(); } else { - own = vector_new(32); + own = vector_new_with_cap(32); } } @@ -293,7 +295,7 @@ filesync(const char *restrict srcpath, const char *restrict dstpath, sprintf(entdst, "%s/%s", dstpath, ent->d_name); if (cleanup) { char *name = strdup(ent->d_name); - hashmap_insert(preserved, name, name); + hmap_set(preserved, name, name); if (own) { vector_push(own, name); } @@ -307,12 +309,12 @@ filesync(const char *restrict srcpath, const char *restrict dstpath, if (cleanup) { rmextra(dstpath, preserved, NULL, NULL, dry); if (own) { - for (size_t i = 0; i < own->size; i++) { + for (size_t i = 0; i < own->len; i++) { free(own->values[i]); } vector_free(own); } else { - hashmap_destroy(preserved, hm_destroy_callback); + hmap_destroy(preserved, hm_destroy_cb); } } -- cgit v1.2.3