Browse Source

stack interface changes

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@307 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 15 years ago
parent
commit
da00589b96
  1. 2
      processor/main.m4
  2. 6
      stack.c
  3. 5
      stack.h
  4. 6
      xcache.c

2
processor/main.m4

@ -38,7 +38,7 @@ define(`ALLOC', `
')
IFSTORE(`
IFASSERT(`{
if (!xc_stack_size(&processor->allocsizes)) {
if (!xc_stack_count(&processor->allocsizes)) {
fprintf(stderr, "mismatch `$@' at line %d\n", __LINE__);
}
else {

6
stack.c

@ -3,10 +3,10 @@
#include "stack.h"
typedef xc_stack_t* S;
void xc_stack_init(S stack)
void xc_stack_init_ex(S stack, int initsize)
{
stack->cnt = 0;
stack->size = 8;
stack->size = initsize;
stack->data = malloc(sizeof(void *) * stack->size);
}
@ -42,7 +42,7 @@ void* xc_stack_get(S stack, int n)
return stack->data[n];
}
int xc_stack_size(S stack)
int xc_stack_count(S stack)
{
assert(stack != NULL);
return stack->cnt;

5
stack.h

@ -6,12 +6,13 @@ typedef struct {
} xc_stack_t;
#define S xc_stack_t*
void xc_stack_init(S stack);
void xc_stack_init_ex(S stack, int initsize);
#define xc_stack_init(stack) xc_stack_init_ex(stack, 8)
void xc_stack_destroy(S stack);
void xc_stack_push(S stack, void *item);
void *xc_stack_pop(S stack);
void *xc_stack_top(S stack);
void *xc_stack_get(S stack, int n);
int xc_stack_size(S stack);
int xc_stack_count(S stack);
void xc_stack_reverse(S stack);
#undef S

6
xcache.c

@ -605,11 +605,11 @@ static inline void xc_entry_unholds_real(xc_stack_t *holds, xc_cache_t **caches,
for (i = 0; i < cachecount; i ++) {
s = &holds[i];
TRACE("holded %d", xc_stack_size(s));
if (xc_stack_size(s)) {
TRACE("holded %d", xc_stack_count(s));
if (xc_stack_count(s)) {
cache = ((xc_entry_t *)xc_stack_top(s))->cache;
ENTER_LOCK(cache) {
while (xc_stack_size(s)) {
while (xc_stack_count(s)) {
xce = (xc_entry_t*) xc_stack_pop(s);
TRACE("unhold %s", xce->name.str.val);
xce->refcount --;

Loading…
Cancel
Save