Go to the source code of this file.
Data Structures | |
struct | translate_cache |
Functions | |
struct translate_cache * | translate_cache_create (void) |
static void | delete_translates (struct translate_cache *cache) |
void | translate_cache_destroy (struct translate_cache *cache) |
static unsigned | translate_hash_key_size (struct translate_key *key) |
static unsigned | create_key (struct translate_key *key) |
struct translate * | translate_cache_find (struct translate_cache *cache, struct translate_key *key) |
Will try to find a translate structure matched by the given key. |
static unsigned create_key | ( | struct translate_key * | key | ) | [static] |
Definition at line 76 of file translate_cache.c.
References cso_construct_key(), hash_key(), and translate_hash_key_size().
00077 { 00078 unsigned hash_key; 00079 unsigned size = translate_hash_key_size(key); 00080 /*debug_printf("key size = %d, (els = %d)\n", 00081 size, key->nr_elements);*/ 00082 hash_key = cso_construct_key(key, size); 00083 return hash_key; 00084 }
static void delete_translates | ( | struct translate_cache * | cache | ) | [static] |
Definition at line 48 of file translate_cache.c.
References cso_hash_first_node(), cso_hash_iter_data(), cso_hash_iter_is_null(), cso_hash_iter_next(), translate_cache::hash, and translate::release.
00049 { 00050 struct cso_hash *hash = cache->hash; 00051 struct cso_hash_iter iter = cso_hash_first_node(hash); 00052 while (!cso_hash_iter_is_null(iter)) { 00053 struct translate *state = (struct translate*)cso_hash_iter_data(iter); 00054 iter = cso_hash_iter_next(iter); 00055 if (state) { 00056 state->release(state); 00057 } 00058 } 00059 }
struct translate_cache* translate_cache_create | ( | void | ) | [read] |
Definition at line 40 of file translate_cache.c.
References cso_hash_create(), translate_cache::hash, and MALLOC_STRUCT.
00041 { 00042 struct translate_cache *cache = MALLOC_STRUCT(translate_cache); 00043 cache->hash = cso_hash_create(); 00044 return cache; 00045 }
void translate_cache_destroy | ( | struct translate_cache * | cache | ) |
Definition at line 61 of file translate_cache.c.
References cso_hash_delete(), delete_translates(), FREE, and translate_cache::hash.
00062 { 00063 delete_translates(cache); 00064 cso_hash_delete(cache->hash); 00065 FREE(cache); 00066 }
struct translate* translate_cache_find | ( | struct translate_cache * | cache, | |
struct translate_key * | key | |||
) | [read] |
Will try to find a translate structure matched by the given key.
If such a structure doesn't exist in the cache the function will automatically create it, insert it in the cache and return the created version.
Definition at line 86 of file translate_cache.c.
References create_key(), cso_hash_find_data_from_template(), cso_hash_insert(), translate_cache::hash, hash_key(), and translate_create().
00088 { 00089 unsigned hash_key = create_key(key); 00090 struct translate *translate = (struct translate*) 00091 cso_hash_find_data_from_template(cache->hash, 00092 hash_key, 00093 key, sizeof(*key)); 00094 00095 if (!translate) { 00096 /* create/insert */ 00097 translate = translate_create(key); 00098 cso_hash_insert(cache->hash, hash_key, translate); 00099 } 00100 00101 return translate; 00102 }
static unsigned translate_hash_key_size | ( | struct translate_key * | key | ) | [static] |
Definition at line 69 of file translate_cache.c.
References translate_key::nr_elements, and PIPE_MAX_ATTRIBS.
00070 { 00071 unsigned size = sizeof(struct translate_key) - 00072 sizeof(struct translate_element) * (PIPE_MAX_ATTRIBS - key->nr_elements); 00073 return size; 00074 }