]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/cache/top: fix a minor `const` nit
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 25 Nov 2025 13:55:47 +0000 (14:55 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 1 Dec 2025 12:27:11 +0000 (13:27 +0100)
lib/cache/api.c
lib/cache/top.c
lib/cache/top.h

index 003b73513fbccd1bfe0a3d9e025454d43a95d277..fa43d14a33964e7eba031a2aefed688dde45f637 100644 (file)
@@ -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);
index 5ff78420229e707e0e4f9da8fb647dade60995b9..8adc1865eabf0dd54ce358191060dbcd01902c23 100644 (file)
@@ -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) {
index cb1353fcfdfa1c742eeb388b1a5602b19645df46..aee50569070dc4cacc6a93e47bbeef8cf74d8bfe 100644 (file)
@@ -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