Lines Matching refs:sl

54 	struct slabhash* sl = (struct slabhash*)calloc(1, 
56 if(!sl) return NULL;
57 sl->size = numtables;
58 log_assert(sl->size > 0);
59 sl->array = (struct lruhash**)calloc(sl->size, sizeof(struct lruhash*));
60 if(!sl->array) {
61 free(sl);
64 sl->mask = (uint32_t)(sl->size - 1);
65 if(sl->mask == 0) {
66 sl->shift = 0;
68 log_assert( (sl->size & sl->mask) == 0
70 sl->shift = 0;
71 while(!(sl->mask & 0x80000000)) {
72 sl->mask <<= 1;
73 sl->shift ++;
76 for(i=0; i<sl->size; i++) {
77 sl->array[i] = lruhash_create(start_size, maxmem / sl->size,
79 if(!sl->array[i]) {
80 slabhash_delete(sl);
84 return sl;
87 void slabhash_delete(struct slabhash* sl)
89 if(!sl)
91 if(sl->array) {
93 for(i=0; i<sl->size; i++)
94 lruhash_delete(sl->array[i]);
95 free(sl->array);
97 free(sl);
100 void slabhash_clear(struct slabhash* sl)
103 if(!sl)
105 for(i=0; i<sl->size; i++)
106 lruhash_clear(sl->array[i]);
111 slab_idx(struct slabhash* sl, hashvalue_type hash)
113 return ((hash & sl->mask) >> sl->shift);
116 void slabhash_insert(struct slabhash* sl, hashvalue_type hash,
119 lruhash_insert(sl->array[slab_idx(sl, hash)], hash, entry, data, arg);
122 struct lruhash_entry* slabhash_lookup(struct slabhash* sl,
125 return lruhash_lookup(sl->array[slab_idx(sl, hash)], hash, key, wr);
128 void slabhash_remove(struct slabhash* sl, hashvalue_type hash, void* key)
130 lruhash_remove(sl->array[slab_idx(sl, hash)], hash, key);
133 void slabhash_status(struct slabhash* sl, const char* id, int extended)
138 id, (unsigned)sl->size, (unsigned)sl->mask, sl->shift);
139 for(i=0; i<sl->size; i++) {
141 lruhash_status(sl->array[i], num, extended);
145 size_t slabhash_get_size(struct slabhash* sl)
148 for(i=0; i<sl->size; i++) {
149 lock_quick_lock(&sl->array[i]->lock);
150 total += sl->array[i]->space_max;
151 lock_quick_unlock(&sl->array[i]->lock);
156 int slabhash_is_size(struct slabhash* sl, size_t size, size_t slabs)
161 if(!sl) return 0;
162 if(sl->size != slabs) return 0;
164 if( (size/slabs)*slabs == slabhash_get_size(sl))
169 size_t slabhash_get_mem(struct slabhash* sl)
171 size_t i, total = sizeof(*sl);
172 total += sizeof(struct lruhash*)*sl->size;
173 for(i=0; i<sl->size; i++) {
174 total += lruhash_get_mem(sl->array[i]);
179 struct lruhash* slabhash_gettable(struct slabhash* sl, hashvalue_type hash)
181 return sl->array[slab_idx(sl, hash)];
218 void slabhash_setmarkdel(struct slabhash* sl, lruhash_markdelfunc_type md)
221 for(i=0; i<sl->size; i++) {
222 lruhash_setmarkdel(sl->array[i], md);