changeset 81272:1842d7137ff2

(init_strings): Initialize canonical empty strings. (make_uninit_string, make_uninit_multibyte_string): Return appropriate canonical empty string when the requested size is 0.
author Juanma Barranquero <lekktu@gmail.com>
date Fri, 08 Jun 2007 19:59:46 +0000
parents 0aafd69cb508
children 13e433477b6c
files src/alloc.c
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/alloc.c	Fri Jun 08 19:58:33 2007 +0000
+++ b/src/alloc.c	Fri Jun 08 19:59:46 2007 +0000
@@ -1756,6 +1756,8 @@
   string_blocks = NULL;
   n_string_blocks = 0;
   string_free_list = NULL;
+  empty_unibyte_string = make_pure_string ("", 0, 0, 0);
+  empty_multibyte_string = make_pure_string ("", 0, 0, 1);
 }
 
 
@@ -2479,6 +2481,9 @@
      int length;
 {
   Lisp_Object val;
+
+  if (!length)
+    return empty_unibyte_string;
   val = make_uninit_multibyte_string (length, length);
   STRING_SET_UNIBYTE (val);
   return val;
@@ -2497,6 +2502,8 @@
 
   if (nchars < 0)
     abort ();
+  if (!nbytes)
+    return empty_multibyte_string;
 
   s = allocate_string ();
   allocate_string_data (s, nchars, nbytes);