[Spice-devel] [PATCH spice 17/17] spicec-x11: If the clipboard was large return the memory to the system

Hans de Goede hdegoede at redhat.com
Mon Oct 4 03:35:08 PDT 2010


---
 client/x11/platform.cpp |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
index 836561e..28530ea 100644
--- a/client/x11/platform.cpp
+++ b/client/x11/platform.cpp
@@ -2445,7 +2445,14 @@ exit:
 
 static void get_selection_free(unsigned char *data, bool incr)
 {
-    if (!incr && data)
+    if (incr) {
+        /* If the clipboard was large return the memory to the system */
+        if (clipboard_data_space > 512 * 1024) {
+            free(clipboard_data);
+            clipboard_data = NULL;
+            clipboard_data_space = 0;
+        }
+    } else if (data)
         XFree(data);
 }
 
-- 
1.7.2.2



More information about the Spice-devel mailing list