]> git.eshelyaron.com Git - emacs.git/commitdiff
(lisp_data_to_selection_data): New arg NOFREE_RET.
authorRichard M. Stallman <rms@gnu.org>
Sun, 25 Jul 1993 22:00:25 +0000 (22:00 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sun, 25 Jul 1993 22:00:25 +0000 (22:00 +0000)
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.

src/xselect.c

index 31113acd38eb3f8b718be45376af52b1c1939a9c..891523a5fa624f1d2f0226a705ecb7548de3899f 100644 (file)
@@ -640,8 +640,10 @@ x_handle_selection_request (event)
       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 @@ x_handle_selection_request (event)
       /* 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 @@ selection_data_to_lisp_data (display, data, size, type, format)
 
 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 @@ lisp_data_to_selection_data (display, obj,
     {
       *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))