1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-08 04:30:45 -08:00

New C macro AUTO_STRING_WITH_LEN

Put a bit less pressure on the garbage collector by defining a
macro that is like AUTO_STRING but also allows null bytes in strings,
and by extending AUTO_STRING to work with any unibyte string.
* src/alloc.c (verify_ascii): Remove; all uses removed.
AUTO_STRING can now be used on non-ASCII unibyte strings.
* src/lisp.h (AUTO_STRING): Now allows non-ASCII unibyte strings.
(AUTO_STRING_WITH_LEN): New macro.
* src/coding.c (from_unicode_buffer):
* src/editfns.c (format_time_string):
* src/emacs-module.c (module_make_string, module_format_fun_env):
* src/fileio.c (Fexpand_file_name):
* src/font.c (font_parse_family_registry):
* src/ftfont.c (ftfont_get_charset):
* src/keymap.c (silly_event_symbol_error):
* src/menu.c (single_menu_item):
* src/sysdep.c (system_process_attributes):
Use AUTO_STRING_WITH_LEN if possible.
* src/emacs-module.c (module_make_function):
* src/fileio.c (report_file_errno, report_file_notify_error):
* src/fns.c (Flocale_info):
* src/sysdep.c (system_process_attributes):
Use AUTO_STRING if possible.  This is doable more often now
that AUTO_STRING works on any unibyte string.
This commit is contained in:
Paul Eggert 2016-04-04 10:30:41 -07:00
parent 0322457e2b
commit 17cb263adb
12 changed files with 63 additions and 77 deletions

View file

@ -8419,11 +8419,10 @@ from_unicode (Lisp_Object str)
Lisp_Object
from_unicode_buffer (const wchar_t *wstr)
{
return from_unicode (
make_unibyte_string (
(char *) wstr,
/* we get one of the two final 0 bytes for free. */
1 + sizeof (wchar_t) * wcslen (wstr)));
/* We get one of the two final null bytes for free. */
prtdiff_t len = 1 + sizeof (wchar_t) * wcslen (wstr);
AUTO_STRING_WITH_LEN (str, (char *) wstr, len);
return from_unicode (str);
}
wchar_t *