[Spice-devel] [RFC v4 62/62] server/red_worker: DEBUG_CURSORS

Alon Levy alevy at redhat.com
Tue Apr 26 03:55:27 PDT 2011


Add cursor allocation debugging code that is turned off as long as
DEBUG_CURSORS is not defined.
---
 server/red_worker.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/server/red_worker.c b/server/red_worker.c
index 3e1a56a..b94cd72 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -78,6 +78,7 @@
 //#define DRAW_ALL
 //#define COMPRESS_DEBUG
 //#define ACYCLIC_SURFACE_DEBUG
+//#define DEBUG_CURSORS
 
 //#define UPDATE_AREA_BY_TREE
 
@@ -4396,12 +4397,20 @@ static void red_set_cursor(RedWorker *worker, CursorItem *cursor)
     worker->cursor = cursor;
 }
 
+#ifdef DEBUG_CURSORS
+static int _cursor_count = 0;
+#endif
+
 static inline CursorItem *alloc_cursor_item(RedWorker *worker)
 {
     CursorItem *cursor;
+
     if (!worker->free_cursor_items) {
         return NULL;
     }
+#ifdef DEBUG_CURSORS
+    --_cursor_count;
+#endif
     cursor = &worker->free_cursor_items->u.cursor_item;
     worker->free_cursor_items = worker->free_cursor_items->u.next;
     return cursor;
@@ -4411,6 +4420,10 @@ static inline void free_cursor_item(RedWorker *worker, CursorItem *item)
 {
     ((_CursorItem *)item)->u.next = worker->free_cursor_items;
     worker->free_cursor_items = (_CursorItem *)item;
+#ifdef DEBUG_CURSORS
+    ++_cursor_count;
+    ASSERT(_cursor_count <= NUM_CURSORS);
+#endif
 }
 
 static void cursor_items_init(RedWorker *worker)
-- 
1.7.4.4



More information about the Spice-devel mailing list