1 | struct cache_entry; |
1 | struct cache_entry |
|
|
2 | { |
|
|
3 | int usage; |
|
|
4 | int size; |
|
|
5 | struct cache_entry_list *where; |
|
|
6 | struct cache_entry *next; |
|
|
7 | struct cache_entry *prev; |
|
|
8 | int id[0]; |
|
|
9 | }; |
|
|
10 | |
|
|
11 | struct cache_entry_list |
|
|
12 | { |
|
|
13 | struct cache_entry *first, *last; |
|
|
14 | int size; |
|
|
15 | }; |
|
|
16 | |
2 | struct cache; |
17 | struct cache |
|
|
18 | { |
|
|
19 | struct cache_entry_list t1, b1, t2, b2, *insert; |
|
|
20 | int size, id_size, entry_size; |
|
|
21 | int t1_target; |
|
|
22 | long misses; |
|
|
23 | long hits; |
|
|
24 | GHashTable *hash; |
|
|
25 | // long long real_size_bytes; |
|
|
26 | }; |
|
|
27 | |
3 | /* prototypes */ |
28 | /* prototypes */ |
4 | struct cache *cache_new(int id_size, int size); |
29 | struct cache *cache_new(int id_size, int size); |
5 | void *cache_entry_new(struct cache *cache, void *id, int size); |
30 | void *cache_entry_new(struct cache *cache, void *id, int size); |
6 | void cache_entry_destroy(struct cache *cache, void *data); |
31 | void cache_entry_destroy(struct cache *cache, void *data); |
7 | void *cache_lookup(struct cache *cache, void *id); |
32 | void *cache_lookup(struct cache *cache, void *id); |