1 |
zoff99 |
31 |
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 |
|
|
|
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 |
|
|
|
28 |
zoff99 |
2 |
/* prototypes */
|
29 |
|
|
struct cache *cache_new(int id_size, int size);
|
30 |
|
|
void *cache_entry_new(struct cache *cache, void *id, int size);
|
31 |
|
|
void cache_entry_destroy(struct cache *cache, void *data);
|
32 |
|
|
void *cache_lookup(struct cache *cache, void *id);
|
33 |
|
|
void cache_insert(struct cache *cache, void *data);
|
34 |
|
|
void *cache_insert_new(struct cache *cache, void *id, int size);
|
35 |
|
|
void cache_flush(struct cache *cache, void *id);
|
36 |
zoff99 |
27 |
void cache_stats(struct cache *cache);
|
37 |
zoff99 |
2 |
void cache_dump(struct cache *cache);
|
38 |
|
|
/* end of prototypes */
|