util/disk_cache: move cache path strdup call back into disk_cache.c
authorTimothy Arceri <tarceri@itsqueeze.com>
Mon, 2 Nov 2020 02:31:32 +0000 (13:31 +1100)
committerMarge Bot <eric+marge@anholt.net>
Sun, 21 Feb 2021 02:50:45 +0000 (02:50 +0000)
This code is already OS agnostic and moving it here enables code
sharing in the following patches.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7725>

src/util/disk_cache.c
src/util/disk_cache_os.c

index bf77fe0..b568b82 100644 (file)
@@ -107,6 +107,10 @@ disk_cache_create(const char *gpu_name, const char *driver_id,
    if (!path)
       goto path_fail;
 
+   cache->path = ralloc_strdup(cache, path);
+   if (cache->path == NULL)
+      goto path_fail;
+
    if (!disk_cache_mmap_cache_index(local, cache, path))
       goto path_fail;
 
index 52de69e..64d6fab 100644 (file)
@@ -930,10 +930,6 @@ disk_cache_mmap_cache_index(void *mem_ctx, struct disk_cache *cache,
    int fd = -1;
    bool mapped = false;
 
-   cache->path = ralloc_strdup(cache, path);
-   if (cache->path == NULL)
-      goto path_fail;
-
    path = ralloc_asprintf(mem_ctx, "%s/index", cache->path);
    if (path == NULL)
       goto path_fail;