From: Jan Djärv Date: Thu, 17 Jun 2004 14:37:53 +0000 (+0000) Subject: * fns.c (string_to_multibyte): Use xmalloc/xfree instead of alloca. X-Git-Tag: ttn-vms-21-2-B4~5728 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a6cb6b787e03344d28e93bef1cce5a7930854158;p=emacs.git * fns.c (string_to_multibyte): Use xmalloc/xfree instead of alloca. --- diff --git a/src/ChangeLog b/src/ChangeLog index 15cd195b4ed..298e2a5808d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2004-06-17 Jan Dj,Ad(Brv + * fns.c (string_to_multibyte): Use xmalloc/xfree instead of alloca. + * macfns.c (Fx_display_color_cells): Do not limit return value to 256. * macterm.c (mac_initialize_display_info): Initialize n_planes correctly 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,