static void * _freed_pool_get (freed_pool_t *pool) { void *ptr; int i; i = pool->top - 1; if (i < 0) i = 0; ptr = _atomic_fetch (&pool->pool[i]); if (ptr != NULL) { pool->top = i; return ptr; } /* either empty or contended */ for (i = ARRAY_LENGTH (pool->pool); i--;) { ptr = _atomic_fetch (&pool->pool[i]); if (ptr != NULL) { pool->top = i; return ptr; } } /* empty */ pool->top = 0; return NULL; }
void * _freed_pool_get_search (freed_pool_t *pool) { void *ptr; int i; for (i = ARRAY_LENGTH (pool->pool); i--;) { ptr = _atomic_fetch (&pool->pool[i]); if (ptr != NULL) { _cairo_atomic_int_set_relaxed (&pool->top, i); return ptr; } } /* empty */ _cairo_atomic_int_set_relaxed (&pool->top, 0); return NULL; }