Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
cache.c File Reference
#include "config.h"
#include "caches/cache.h"
#include "system/dtpthread.h"
#include "system/macros.h"
#include "system/mem_alloc.h"
#include <assert.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for src/caches/cache.c:

Go to the source code of this file.

Functions

static void _cache_gc_locked (dt_cache_t *cache, const float fill_ratio)
void dt_cache_init (dt_cache_t *cache, size_t entry_size, size_t cost_quota)
void dt_cache_cleanup (dt_cache_t *cache)
int32_t dt_cache_contains (dt_cache_t *cache, const uint32_t key)
int dt_cache_for_all (dt_cache_t *cache, int(*process)(const uint32_t key, const void *data, void *user_data), void *user_data)
dt_cache_entry_t * dt_cache_testget (dt_cache_t *cache, const uint32_t key, char mode)
dt_cache_entry_t * dt_cache_get_with_caller (dt_cache_t *cache, const uint32_t key, char mode, const char *file, int line)
int dt_cache_remove (dt_cache_t *cache, const uint32_t key)
size_t dt_cache_gc (dt_cache_t *cache, const float fill_ratio)
void dt_cache_release_with_caller (dt_cache_t *cache, dt_cache_entry_t *entry, const char *file, int line)
int dt_cache_seed (dt_cache_t *cache, const uint32_t key, const void *data, size_t data_size, size_t cost)
dt_cache_entry_t * dt_cache_entry_new_detached (void)
 Allocate a cache entry that belongs to NO cache, for a one-shot decode.
void dt_cache_entry_free_detached (dt_cache_entry_t *entry)
 Release an entry from dt_cache_entry_new_detached(), and its data. NULL-safe.

Function Documentation

◆ _cache_gc_locked()

◆ dt_cache_cleanup()

◆ dt_cache_contains()

int32_t dt_cache_contains ( dt_cache_t * cache,
const uint32_t key )

◆ dt_cache_entry_free_detached()

void dt_cache_entry_free_detached ( dt_cache_entry_t * entry)

Release an entry from dt_cache_entry_new_detached(), and its data. NULL-safe.

Definition at line 473 of file src/caches/cache.c.

References dt_cache_entry_t::data, dt_free_align, and IS_NULL_PTR.

Referenced by dt_imageio_close_standalone().

◆ dt_cache_entry_new_detached()

dt_cache_entry_t * dt_cache_entry_new_detached ( void )

Allocate a cache entry that belongs to NO cache, for a one-shot decode.

The decoders write into whatever dt_cache_entry_t they are handed, which is normally one the mipmap cache owns. A caller that just wants a file decoded once has no cache to get one from, and used to declare a zeroed entry on its own stack – assembling this module's bookkeeping by hand to borrow a decoder. These two exist so nothing outside src/caches needs the layout.

Returns
An entry whose data is NULL, or NULL on allocation failure. Release it with dt_cache_entry_free_detached(), which frees data too.
See also
dt_imageio_open_standalone(), its only caller.

Definition at line 468 of file src/caches/cache.c.

Referenced by dt_imageio_open_standalone().

◆ dt_cache_for_all()

int dt_cache_for_all ( dt_cache_t * cache,
int(* process )(const uint32_t key, const void *data, void *user_data),
void * user_data )

◆ dt_cache_gc()

size_t dt_cache_gc ( dt_cache_t * cache,
const float fill_ratio )

◆ dt_cache_get_with_caller()

◆ dt_cache_init()

◆ dt_cache_release_with_caller()

void dt_cache_release_with_caller ( dt_cache_t * cache,
dt_cache_entry_t * entry,
const char * file,
int line )

◆ dt_cache_remove()

◆ dt_cache_seed()

◆ dt_cache_testget()