diff options
author | Juanma Barranquero <[email protected]> | 2007-06-08 19:59:46 +0000 |
---|---|---|
committer | Juanma Barranquero <[email protected]> | 2007-06-08 19:59:46 +0000 |
commit | 4d774b0fe6a4f6c0df213cc176b76dd453af3911 (patch) | |
tree | a40afa54cd52f869545e92f1d9162ba1339341f4 /src | |
parent | 7e9fa161dccd2990ea344c4b4b7188383de76a55 (diff) |
(init_strings): Initialize canonical empty strings.
(make_uninit_string, make_uninit_multibyte_string): Return appropriate
canonical empty string when the requested size is 0.
Diffstat (limited to 'src')
-rw-r--r-- | src/alloc.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/alloc.c b/src/alloc.c index 68b490f98b..7668309e59 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1756,6 +1756,8 @@ init_strings () 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 @@ make_uninit_string (length) 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 @@ make_uninit_multibyte_string (nchars, nbytes) if (nchars < 0) abort (); + if (!nbytes) + return empty_multibyte_string; s = allocate_string (); allocate_string_data (s, nchars, nbytes); |