diff options
author | OpenGnSys Support Team <soporte-og@soleta.eu> | 2024-09-25 14:47:06 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2024-09-25 14:49:17 +0200 |
commit | 3c395ecea2bb538cf5182a64df503329a0a1cbcc (patch) | |
tree | cab60d6323743922409411cf73c1a1e44e3f0f31 /src/json.c | |
parent | 65aee8f3f32f8f936aa272301ad69fc38c0f258c (diff) |
client: move image list to cache data to consolidate it
Move list of images in the cache to cache_data. Add new functions to
initialize cache data (image list) and release it.
Diffstat (limited to 'src/json.c')
-rw-r--r-- | src/json.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -241,11 +241,16 @@ int og_json_parse_procedure(json_t *element, struct og_procedure *proc) return err; } -void og_cache_image_free(struct list_head *cache_list) +void og_cache_data_init(struct og_cache_data *cache_data) +{ + INIT_LIST_HEAD(&cache_data->image_list); +} + +void og_cache_data_free(struct og_cache_data *cache_data) { struct og_cache_image *cache_item, *tmp; - list_for_each_entry_safe(cache_item, tmp, cache_list, list) { + list_for_each_entry_safe(cache_item, tmp, &cache_data->image_list, list) { list_del(&cache_item->list); free(cache_item); } @@ -308,7 +313,7 @@ static int og_json_parse_cache_images(json_t *element, struct list_head *cache_l return err; } -int og_json_parse_cache(json_t *element, struct og_cache_data *cache_data, struct list_head *cache_list) +int og_json_parse_cache(json_t *element, struct og_cache_data *cache_data) { uint64_t required_flags = OG_PARAM_CACHE_FREE_SIZE | OG_PARAM_CACHE_USED_SIZE | OG_PARAM_CACHE_IMAGES; uint64_t flags = 0UL; @@ -330,7 +335,7 @@ int og_json_parse_cache(json_t *element, struct og_cache_data *cache_data, struc err = og_json_parse_uint64(value, &cache_data->free_size); flags |= OG_PARAM_CACHE_FREE_SIZE; } else if (!strcmp(key, "images")) { - err = og_json_parse_cache_images(value, cache_list); + err = og_json_parse_cache_images(value, &cache_data->image_list); flags |= OG_PARAM_CACHE_IMAGES; } else err = -1; |