Debian Codegraph @

crt/aws-c-common/source/cache.c

raw symbols SCIP
1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5 #include <aws/common/cache.h>
6
7 void aws_cache_destroy(struct aws_cache *cache) {
8 AWS_PRECONDITION(cache);
9 cache->vtable->destroy(cache);
10 }
11
12 int aws_cache_find(struct aws_cache *cache, const void *key, void **p_value) {
13 AWS_PRECONDITION(cache);
14 return cache->vtable->find(cache, key, p_value);
15 }
16
17 int aws_cache_put(struct aws_cache *cache, const void *key, void *p_value) {
18 AWS_PRECONDITION(cache);
19 return cache->vtable->put(cache, key, p_value);
20 }
21
22 int aws_cache_remove(struct aws_cache *cache, const void *key) {
23 AWS_PRECONDITION(cache);
24 return cache->vtable->remove(cache, key);
25 }
26
27 void aws_cache_clear(struct aws_cache *cache) {
28 AWS_PRECONDITION(cache);
29 cache->vtable->clear(cache);
30 }
31
32 size_t aws_cache_get_element_count(const struct aws_cache *cache) {
33 AWS_PRECONDITION(cache);
34 return cache->vtable->get_element_count(cache);
35 }
36
37 void aws_cache_base_default_destroy(struct aws_cache *cache) {
38 aws_linked_hash_table_clean_up(&cache->table);
39 aws_mem_release(cache->allocator, cache);
40 }
41
42 int aws_cache_base_default_find(struct aws_cache *cache, const void *key, void **p_value) {
43 return (aws_linked_hash_table_find(&cache->table, key, p_value));
44 }
45
46 int aws_cache_base_default_remove(struct aws_cache *cache, const void *key) {
47 /* allocated cache memory and the linked list entry will be removed in the
48 * callback. */
49 return aws_linked_hash_table_remove(&cache->table, key);
50 }
51
52 void aws_cache_base_default_clear(struct aws_cache *cache) {
53 /* clearing the table will remove all elements. That will also deallocate
54 * any cache entries we currently have. */
55 aws_linked_hash_table_clear(&cache->table);
56 }
57
58 size_t aws_cache_base_default_get_element_count(const struct aws_cache *cache) {
59 return aws_linked_hash_table_get_element_count(&cache->table);
60 }