diff options
author | Yonit Halperin <yhalperi@redhat.com> | 2011-06-07 12:37:37 +0300 |
---|---|---|
committer | Alon Levy <alevy@redhat.com> | 2011-07-31 12:34:29 +0300 |
commit | 8707bb1b9e42df6f1c658c156250f33b8b488ba8 (patch) | |
tree | 63a34c39fddb1608185381bd29544f7034ea6b01 | |
parent | c2379198bd66c95f339faa1d039cfeea4a0957ab (diff) |
display/res: make (Cursor|Palette)CacheRemove always release the object
even if it is not found in the cache (which is an error)
-rw-r--r-- | display/res.c | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/display/res.c b/display/res.c index 5045b6f..1a5e76e 100644 --- a/display/res.c +++ b/display/res.c @@ -1544,6 +1544,7 @@ static _inline void ReleasePalette(PDev *pdev, InternalPalette *palette) static _inline void PaletteCacheRemove(PDev *pdev, InternalPalette *palette) { InternalPalette **internal; + BOOL found = FALSE; DEBUG_PRINT((pdev, 15, "%s\n", __FUNCTION__)); @@ -1553,15 +1554,22 @@ static _inline void PaletteCacheRemove(PDev *pdev, InternalPalette *palette) while (*internal) { if ((*internal)->palette.unique == palette->palette.unique) { *internal = palette->next; - RingRemove(pdev, &palette->lru_link); - ReleasePalette(pdev, palette); - pdev->Res->num_palettes--; - DEBUG_PRINT((pdev, 16, "%s: done\n", __FUNCTION__)); - return; + found = TRUE; + break; } internal = &(*internal)->next; } - ASSERT(pdev, FALSE); + + RingRemove(pdev, &palette->lru_link); + ReleasePalette(pdev, palette); + pdev->Res->num_palettes--; + + if (!found) { + DEBUG_PRINT((pdev, 0, "%s: Error: palette 0x%x isn't in cache \n", __FUNCTION__, palette)); + ASSERT(pdev, FALSE); + } else { + DEBUG_PRINT((pdev, 16, "%s: done\n", __FUNCTION__)); + } } static _inline InternalPalette *PaletteCacheGet(PDev *pdev, UINT32 unique) @@ -2869,29 +2877,36 @@ typedef struct InternalCursor { static void CursorCacheRemove(PDev *pdev, InternalCursor *cursor) { InternalCursor **internal; + BOOL found = FALSE; DEBUG_PRINT((pdev, 12, "%s\n", __FUNCTION__)); - if (!cursor->unique) { - DEBUG_PRINT((pdev, 1, "%s: cursor not unique\n", __FUNCTION__)); - return; - } + ASSERT(pdev, cursor->unique); internal = &pdev->Res->cursor_cache[CURSOR_HASH_VAL(cursor->hsurf)]; while (*internal) { if ((*internal)->hsurf == cursor->hsurf) { if ((*internal) == cursor) { *internal = cursor->next; - RingRemove(pdev, &cursor->lru_link); - RELEASE_RES(pdev, (Resource *)((UINT8 *)cursor - sizeof(Resource))); - pdev->Res->num_cursors--; - return; + found = TRUE; + break; } DEBUG_PRINT((pdev, 0, "%s: unexpected\n", __FUNCTION__)); } internal = &(*internal)->next; } - DEBUG_PRINT((pdev, 0, "%s: Error: should not reach this\n", __FUNCTION__)); + + RingRemove(pdev, &cursor->lru_link); + RELEASE_RES(pdev, (Resource *)((UINT8 *)cursor - sizeof(Resource))); + pdev->Res->num_cursors--; + + if (!found) { + DEBUG_PRINT((pdev, 0, "%s: Error: cursor 0x%x isn't in cache \n", __FUNCTION__, cursor)); + ASSERT(pdev, FALSE); + } else { + DEBUG_PRINT((pdev, 16, "%s: done\n", __FUNCTION__)); + } + } static void CursorCacheAdd(PDev *pdev, InternalCursor *cursor) |