cache_cache.c revision 98545bfcdf6b9ad9f293cdc0743bb831d785a2f7
/* cache.c */
#include "apr_general.h"
#include "mod_cache.h"
#include "cache_hash.h"
#include "cache_pqueue.h"
#include "cache_cache.h"
#include <stdlib.h>
#endif
#include <string.h>
#endif
struct cache_cache_t {
int max_entries;
int total_purges;
long queue_clock;
};
{
tmp->current_size = 0;
tmp->total_purges = 0;
tmp->queue_clock = 0;
return tmp;
}
{
cache_pq_free(c->pq);
cache_hash_free(c->ht);
free(c);
}
{
void *e;
if (!e)
return NULL;
return e;
}
{
long old_priority;
long new_priority;
}
{
long priority;
/* FIX: check if priority of bottom item is greater than inserted one */
/* FIX: If ejected is NULL, we'll segfault here */
if (c->queue_clock < priority)
c->queue_clock = priority;
cache_hash_set(c->ht,
NULL);
c->free_entry(ejected);
c->total_purges++;
}
}
{
void *entry;
if (!c)
return NULL;
if (!entry)
return NULL;
return entry;
}
{
if (rc != APR_SUCCESS)
return rc;
c->current_size -= entry_size;
return APR_SUCCESS;
}