1
0
Fork 0

stack interface changes

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@307 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 2006-12-09 03:42:09 +00:00
parent fdea5852e4
commit da00589b96
4 changed files with 10 additions and 9 deletions

View File

@ -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 {

View File

@ -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;

View File

@ -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

View File

@ -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 --;