[Spice-devel] [RFCv5 43/47] server/red_worker: DEBUG_CURSORS
Alon Levy
alevy at redhat.com
Sun May 8 06:11:39 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 1e6f495..43373af 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -81,6 +81,7 @@
//#define DRAW_ALL
//#define COMPRESS_DEBUG
//#define ACYCLIC_SURFACE_DEBUG
+//#define DEBUG_CURSORS
//#define UPDATE_AREA_BY_TREE
@@ -4422,12 +4423,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;
@@ -4437,6 +4446,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.5.1
More information about the Spice-devel
mailing list