changeset 4278:889d81e3f507

(lisp_data_to_selection_data): New arg NOFREE_RET. For a string, just return its data's address. (x_handle_selection_request): Pass new arg. If value comes back 1, don't call xfree.
author Richard M. Stallman <rms@gnu.org>
date Sun, 25 Jul 1993 22:00:25 +0000
parents c3fbb9249f5b
children d69483b37e0a
files src/xselect.c
diffstat 1 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/xselect.c	Sun Jul 25 21:50:16 1993 +0000
+++ b/src/xselect.c	Sun Jul 25 22:00:25 1993 +0000
@@ -640,8 +640,10 @@
       unsigned int size;
       int format;
       Atom type;
+      int nofree;
+
       lisp_data_to_selection_data (reply.display, converted_selection,
-				   &data, &type, &size, &format);
+				   &data, &type, &size, &format, &nofree);
       
       x_reply_selection_request (event, format, data, size, type);
       successful_p = Qt;
@@ -649,7 +651,8 @@
       /* Indicate we have successfully processed this event.  */
       x_selection_current_request = 0;
 
-      xfree (data);
+      if (!nofree)
+	xfree (data);
     }
   unbind_to (count, Qnil);
 
@@ -1310,15 +1313,20 @@
 
 static void
 lisp_data_to_selection_data (display, obj,
-			     data_ret, type_ret, size_ret, format_ret)
+			     data_ret, type_ret, size_ret,
+			     format_ret, nofree_ret)
      Display *display;
      Lisp_Object obj;
      unsigned char **data_ret;
      Atom *type_ret;
      unsigned int *size_ret;
      int *format_ret;
+     int *nofree_ret;
 {
   Lisp_Object type = Qnil;
+
+  *nofree_ret = 0;
+
   if (CONSP (obj) && SYMBOLP (XCONS (obj)->car))
     {
       type = XCONS (obj)->car;
@@ -1338,8 +1346,8 @@
     {
       *format_ret = 8;
       *size_ret = XSTRING (obj)->size;
-      *data_ret = (unsigned char *) xmalloc (*size_ret);
-      memcpy (*data_ret, (char *) XSTRING (obj)->data, *size_ret);
+      *data_ret = XSTRING (obj)->data;
+      *nofree_ret = 1;
       if (NILP (type)) type = QSTRING;
     }
   else if (SYMBOLP (obj))