summaryrefslogtreecommitdiff
path: root/src/fns.c
diff options
context:
space:
mode:
authorJan Djärv <jan.h.d@swipnet.se>2004-06-17 14:37:53 +0000
committerJan Djärv <jan.h.d@swipnet.se>2004-06-17 14:37:53 +0000
commita6cb6b787e03344d28e93bef1cce5a7930854158 (patch)
tree09d95d4705935a7a8ac11e6159e642cac869d215 /src/fns.c
parentf303762dc1885b861fe9e9a9a6a5ec618c23ef31 (diff)
downloademacs-a6cb6b787e03344d28e93bef1cce5a7930854158.tar.gz
* fns.c (string_to_multibyte): Use xmalloc/xfree instead of alloca.
Diffstat (limited to 'src/fns.c')
-rw-r--r--src/fns.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/fns.c b/src/fns.c
index 6001d99fb49..9c5a9d1282b 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -1049,16 +1049,24 @@ string_make_unibyte (string)
Lisp_Object string;
{
unsigned char *buf;
+ Lisp_Object ret;
if (! STRING_MULTIBYTE (string))
return string;
- buf = (unsigned char *) alloca (SCHARS (string));
+ /* We can not use alloca here, because string might be very long.
+ For example when selecting megabytes of text and then pasting it to
+ another application. */
+ buf = (unsigned char *) xmalloc (SCHARS (string));
copy_text (SDATA (string), buf, SBYTES (string),
1, 0);
- return make_unibyte_string (buf, SCHARS (string));
+ ret = make_unibyte_string (buf, SCHARS (string));
+
+ xfree (buf);
+
+ return ret;
}
DEFUN ("string-make-multibyte", Fstring_make_multibyte, Sstring_make_multibyte,