diff options
| author | Juanma Barranquero | 2007-06-08 19:59:46 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2007-06-08 19:59:46 +0000 |
| commit | 4d774b0fe6a4f6c0df213cc176b76dd453af3911 (patch) | |
| tree | a40afa54cd52f869545e92f1d9162ba1339341f4 /src/alloc.c | |
| parent | 7e9fa161dccd2990ea344c4b4b7188383de76a55 (diff) | |
| download | emacs-4d774b0fe6a4f6c0df213cc176b76dd453af3911.tar.gz emacs-4d774b0fe6a4f6c0df213cc176b76dd453af3911.zip | |
(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/alloc.c')
| -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 68b490f98b5..7668309e59c 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -1756,6 +1756,8 @@ init_strings () | |||
| 1756 | string_blocks = NULL; | 1756 | string_blocks = NULL; |
| 1757 | n_string_blocks = 0; | 1757 | n_string_blocks = 0; |
| 1758 | string_free_list = NULL; | 1758 | string_free_list = NULL; |
| 1759 | empty_unibyte_string = make_pure_string ("", 0, 0, 0); | ||
| 1760 | empty_multibyte_string = make_pure_string ("", 0, 0, 1); | ||
| 1759 | } | 1761 | } |
| 1760 | 1762 | ||
| 1761 | 1763 | ||
| @@ -2479,6 +2481,9 @@ make_uninit_string (length) | |||
| 2479 | int length; | 2481 | int length; |
| 2480 | { | 2482 | { |
| 2481 | Lisp_Object val; | 2483 | Lisp_Object val; |
| 2484 | |||
| 2485 | if (!length) | ||
| 2486 | return empty_unibyte_string; | ||
| 2482 | val = make_uninit_multibyte_string (length, length); | 2487 | val = make_uninit_multibyte_string (length, length); |
| 2483 | STRING_SET_UNIBYTE (val); | 2488 | STRING_SET_UNIBYTE (val); |
| 2484 | return val; | 2489 | return val; |
| @@ -2497,6 +2502,8 @@ make_uninit_multibyte_string (nchars, nbytes) | |||
| 2497 | 2502 | ||
| 2498 | if (nchars < 0) | 2503 | if (nchars < 0) |
| 2499 | abort (); | 2504 | abort (); |
| 2505 | if (!nbytes) | ||
| 2506 | return empty_multibyte_string; | ||
| 2500 | 2507 | ||
| 2501 | s = allocate_string (); | 2508 | s = allocate_string (); |
| 2502 | allocate_string_data (s, nchars, nbytes); | 2509 | allocate_string_data (s, nchars, nbytes); |