aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1993-07-25 22:00:25 +0000
committerRichard M. Stallman1993-07-25 22:00:25 +0000
commitaca39f42ae739bc665c49ad4b085342cbe7daa83 (patch)
treea405e0afb748d601f3a64a0abbe959acc5ca3ae9 /src
parentc83febd71f9d9f1abd8a0cafe6924112bea60d14 (diff)
downloademacs-aca39f42ae739bc665c49ad4b085342cbe7daa83.tar.gz
emacs-aca39f42ae739bc665c49ad4b085342cbe7daa83.zip
(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.
Diffstat (limited to 'src')
-rw-r--r--src/xselect.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/xselect.c b/src/xselect.c
index 31113acd38e..891523a5fa6 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -640,8 +640,10 @@ x_handle_selection_request (event)
640 unsigned int size; 640 unsigned int size;
641 int format; 641 int format;
642 Atom type; 642 Atom type;
643 int nofree;
644
643 lisp_data_to_selection_data (reply.display, converted_selection, 645 lisp_data_to_selection_data (reply.display, converted_selection,
644 &data, &type, &size, &format); 646 &data, &type, &size, &format, &nofree);
645 647
646 x_reply_selection_request (event, format, data, size, type); 648 x_reply_selection_request (event, format, data, size, type);
647 successful_p = Qt; 649 successful_p = Qt;
@@ -649,7 +651,8 @@ x_handle_selection_request (event)
649 /* Indicate we have successfully processed this event. */ 651 /* Indicate we have successfully processed this event. */
650 x_selection_current_request = 0; 652 x_selection_current_request = 0;
651 653
652 xfree (data); 654 if (!nofree)
655 xfree (data);
653 } 656 }
654 unbind_to (count, Qnil); 657 unbind_to (count, Qnil);
655 658
@@ -1310,15 +1313,20 @@ selection_data_to_lisp_data (display, data, size, type, format)
1310 1313
1311static void 1314static void
1312lisp_data_to_selection_data (display, obj, 1315lisp_data_to_selection_data (display, obj,
1313 data_ret, type_ret, size_ret, format_ret) 1316 data_ret, type_ret, size_ret,
1317 format_ret, nofree_ret)
1314 Display *display; 1318 Display *display;
1315 Lisp_Object obj; 1319 Lisp_Object obj;
1316 unsigned char **data_ret; 1320 unsigned char **data_ret;
1317 Atom *type_ret; 1321 Atom *type_ret;
1318 unsigned int *size_ret; 1322 unsigned int *size_ret;
1319 int *format_ret; 1323 int *format_ret;
1324 int *nofree_ret;
1320{ 1325{
1321 Lisp_Object type = Qnil; 1326 Lisp_Object type = Qnil;
1327
1328 *nofree_ret = 0;
1329
1322 if (CONSP (obj) && SYMBOLP (XCONS (obj)->car)) 1330 if (CONSP (obj) && SYMBOLP (XCONS (obj)->car))
1323 { 1331 {
1324 type = XCONS (obj)->car; 1332 type = XCONS (obj)->car;
@@ -1338,8 +1346,8 @@ lisp_data_to_selection_data (display, obj,
1338 { 1346 {
1339 *format_ret = 8; 1347 *format_ret = 8;
1340 *size_ret = XSTRING (obj)->size; 1348 *size_ret = XSTRING (obj)->size;
1341 *data_ret = (unsigned char *) xmalloc (*size_ret); 1349 *data_ret = XSTRING (obj)->data;
1342 memcpy (*data_ret, (char *) XSTRING (obj)->data, *size_ret); 1350 *nofree_ret = 1;
1343 if (NILP (type)) type = QSTRING; 1351 if (NILP (type)) type = QSTRING;
1344 } 1352 }
1345 else if (SYMBOLP (obj)) 1353 else if (SYMBOLP (obj))