From: Vladimír Čunát Date: Tue, 25 Nov 2025 13:55:47 +0000 (+0100) Subject: lib/cache/top: fix a minor `const` nit X-Git-Tag: v6.0.17~2^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac2728c55fb164461dc53679c1e5c8b148dddc25;p=thirdparty%2Fknot-resolver.git lib/cache/top: fix a minor `const` nit --- diff --git a/lib/cache/api.c b/lib/cache/api.c index 003b73513..fa43d14a3 100644 --- a/lib/cache/api.c +++ b/lib/cache/api.c @@ -161,13 +161,13 @@ int kr_cache_open(struct kr_cache *cache, const struct kr_cdb_api *api, struct k cache->ttl_max = KR_CACHE_DEFAULT_TTL_MAX; kr_cache_make_checkpoint(cache); - char *top_path = kr_absolutize_path(opts->path, "top"); + const char *top_path = kr_absolutize_path(opts->path, "top"); if (kr_fails_assert(top_path)) { ret = kr_error(errno); } if (ret == 0) { ret = kr_cache_top_init(&cache->top, top_path, orig_maxsize); - free(top_path); + free_const(top_path); } if (ret != 0) { cache->api->close(cache->db, &cache->stats); diff --git a/lib/cache/top.c b/lib/cache/top.c index 5ff784202..8adc1865e 100644 --- a/lib/cache/top.c +++ b/lib/cache/top.c @@ -100,7 +100,7 @@ size_t kr_cache_top_get_size(size_t cache_size) return top_size; } -int kr_cache_top_init(struct kr_cache_top *top, char *mmap_file, size_t cache_size) +int kr_cache_top_init(struct kr_cache_top *top, const char *mmap_file, size_t cache_size) { size_t size = 0, capacity_log = 0; if (cache_size > 0) { diff --git a/lib/cache/top.h b/lib/cache/top.h index cb1353fcf..aee505690 100644 --- a/lib/cache/top.h +++ b/lib/cache/top.h @@ -63,7 +63,7 @@ size_t kr_cache_top_get_size(size_t cache_size); /// If cache_size differs from the previously used value, the data are cleared, /// otherwise they are persistent across restarts. KR_EXPORT -int kr_cache_top_init(struct kr_cache_top *top, char *mmap_file, size_t cache_size); +int kr_cache_top_init(struct kr_cache_top *top, const char *mmap_file, size_t cache_size); /// Deinitialize shared memory, keeping the data stored in file. KR_EXPORT