Lines Matching defs:cache
84 rehash(struct gl_program_cache *cache)
90 cache->last = NULL;
92 size = cache->size * 3;
96 for (i = 0; i < cache->size; i++)
97 for (c = cache->items[i]; c; c = next) {
103 free(cache->items);
104 cache->items = items;
105 cache->size = size;
110 clear_cache(struct gl_context *ctx, struct gl_program_cache *cache,
116 cache->last = NULL;
118 for (i = 0; i < cache->size; i++) {
119 for (c = cache->items[i]; c; c = next) {
131 cache->items[i] = NULL;
135 cache->n_items = 0;
143 struct gl_program_cache *cache = CALLOC_STRUCT(gl_program_cache);
144 if (cache) {
145 cache->size = 17;
146 cache->items =
147 calloc(cache->size, sizeof(struct cache_item *));
148 if (!cache->items) {
149 FREE(cache);
153 return cache;
158 _mesa_delete_program_cache(struct gl_context *ctx, struct gl_program_cache *cache)
160 clear_cache(ctx, cache, GL_FALSE);
161 free(cache->items);
162 FREE(cache);
167 struct gl_program_cache *cache)
169 clear_cache(ctx, cache, GL_TRUE);
170 free(cache->items);
171 FREE(cache);
176 _mesa_search_program_cache(struct gl_program_cache *cache,
179 if (cache->last &&
180 cache->last->keysize == keysize &&
181 memcmp(cache->last->key, key, keysize) == 0) {
182 return cache->last->program;
188 for (c = cache->items[hash % cache->size]; c; c = c->next) {
193 cache->last = c;
205 struct gl_program_cache *cache,
220 if (cache->n_items > cache->size * 1.5) {
221 if (cache->size < 1000)
222 rehash(cache);
224 clear_cache(ctx, cache, GL_FALSE);
227 cache->n_items++;
228 c->next = cache->items[hash % cache->size];
229 cache->items[hash % cache->size] = c;
234 struct gl_program_cache *cache,
249 if (cache->n_items > cache->size * 1.5) {
250 if (cache->size < 1000)
251 rehash(cache);
253 clear_cache(ctx, cache, GL_TRUE);
256 cache->n_items++;
257 c->next = cache->items[hash % cache->size];
258 cache->items[hash % cache->size] = c;