comparison src/xselect.c @ 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 507f64624555
children 02a515f35abc
comparison
equal deleted inserted replaced
4277:c3fbb9249f5b 4278:889d81e3f507
638 { 638 {
639 unsigned char *data; 639 unsigned char *data;
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;
648 650
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
656 DONE: 659 DONE:
657 660
1308 } 1311 }
1309 1312
1310 1313
1311 static void 1314 static void
1312 lisp_data_to_selection_data (display, obj, 1315 lisp_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;
1325 obj = XCONS (obj)->cdr; 1333 obj = XCONS (obj)->cdr;
1326 if (CONSP (obj) && NILP (XCONS (obj)->cdr)) 1334 if (CONSP (obj) && NILP (XCONS (obj)->cdr))
1336 } 1344 }
1337 else if (STRINGP (obj)) 1345 else if (STRINGP (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))
1346 { 1354 {
1347 *format_ret = 32; 1355 *format_ret = 32;