diff options
-rw-r--r-- | src/intel_list.h | 10 | ||||
-rw-r--r-- | src/sna/sna_dri2.c | 6 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/intel_list.h b/src/intel_list.h index d0408bed..df912a83 100644 --- a/src/intel_list.h +++ b/src/intel_list.h @@ -347,6 +347,11 @@ list_is_empty(const struct list *head) &pos->member != (head); \ pos = tmp, tmp = __container_of(pos->member.next, tmp, member)) +#define list_for_each_entry_safe_from(pos, tmp, head, member) \ + for (tmp = __container_of(pos->member.next, pos, member); \ + &pos->member != (head); \ + pos = tmp, tmp = __container_of(pos->member.next, tmp, member)) + #else #include <list.h> @@ -396,6 +401,11 @@ static inline void list_move_tail(struct list *list, struct list *head) &pos->member != (head); \ pos = __container_of(pos->member.prev, pos, member)) +#define list_for_each_entry_safe_from(pos, tmp, head, member) \ + for (tmp = __container_of(pos->member.next, pos, member) \ + &pos->member != (head); \ + pos = tmp) + #endif #undef container_of diff --git a/src/sna/sna_dri2.c b/src/sna/sna_dri2.c index bae93148..e6f4d43d 100644 --- a/src/sna/sna_dri2.c +++ b/src/sna/sna_dri2.c @@ -1510,10 +1510,10 @@ sna_dri2_remove_event(WindowPtr win, struct sna_dri2_event *info) priv->chain = info->chain; if (priv->chain == NULL) { - while (!list_is_empty(&priv->cache)) { - struct dri_bo *c; + struct dri_bo *c, *tmp; - c = list_first_entry(&priv->cache, struct dri_bo, link); + c = list_entry(priv->cache.next->next, struct dri_bo, link); + list_for_each_entry_safe_from(c, tmp, &priv->cache, link) { list_del(&c->link); DBG(("%s: releasing cached handle=%d\n", __FUNCTION__, c->bo ? c->bo->handle : 0)); |