diff options
| author | Paul Eggert | 2016-04-04 10:30:41 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-04-04 10:31:25 -0700 |
| commit | 17cb263adb7c37803140604f0a2e4df8a38fbcff (patch) | |
| tree | bd57929386123132847718e2d30a528c8b19d1a3 /src/emacs-module.c | |
| parent | 0322457e2bec0b9409a03887a8235dbe14e357f4 (diff) | |
| download | emacs-17cb263adb7c37803140604f0a2e4df8a38fbcff.tar.gz emacs-17cb263adb7c37803140604f0a2e4df8a38fbcff.zip | |
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.
Diffstat (limited to 'src/emacs-module.c')
| -rw-r--r-- | src/emacs-module.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c index b57636e54e5..724d24a7768 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -395,11 +395,13 @@ module_make_function (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity, | |||
| 395 | envptr->data = data; | 395 | envptr->data = data; |
| 396 | 396 | ||
| 397 | Lisp_Object envobj = make_save_ptr (envptr); | 397 | Lisp_Object envobj = make_save_ptr (envptr); |
| 398 | Lisp_Object doc | 398 | Lisp_Object doc = Qnil; |
| 399 | = (documentation | 399 | if (documentation) |
| 400 | ? code_convert_string_norecord (build_unibyte_string (documentation), | 400 | { |
| 401 | Qutf_8, false) | 401 | AUTO_STRING (unibyte_doc, documentation); |
| 402 | : Qnil); | 402 | doc = code_convert_string_norecord (unibyte_doc, Qutf_8, false); |
| 403 | } | ||
| 404 | |||
| 403 | /* FIXME: Use a bytecompiled object, or even better a subr. */ | 405 | /* FIXME: Use a bytecompiled object, or even better a subr. */ |
| 404 | Lisp_Object ret = list4 (Qlambda, | 406 | Lisp_Object ret = list4 (Qlambda, |
| 405 | list2 (Qand_rest, Qargs), | 407 | list2 (Qand_rest, Qargs), |
| @@ -537,7 +539,7 @@ static emacs_value | |||
| 537 | module_make_string (emacs_env *env, const char *str, ptrdiff_t length) | 539 | module_make_string (emacs_env *env, const char *str, ptrdiff_t length) |
| 538 | { | 540 | { |
| 539 | MODULE_FUNCTION_BEGIN (module_nil); | 541 | MODULE_FUNCTION_BEGIN (module_nil); |
| 540 | Lisp_Object lstr = make_unibyte_string (str, length); | 542 | AUTO_STRING_WITH_LEN (lstr, str, length); |
| 541 | return lisp_to_value (code_convert_string_norecord (lstr, Qutf_8, false)); | 543 | return lisp_to_value (code_convert_string_norecord (lstr, Qutf_8, false)); |
| 542 | } | 544 | } |
| 543 | 545 | ||
| @@ -992,10 +994,12 @@ module_format_fun_env (const struct module_fun_env *env) | |||
| 992 | ? exprintf (&buf, &bufsize, buffer, -1, | 994 | ? exprintf (&buf, &bufsize, buffer, -1, |
| 993 | "#<module function %s from %s>", sym, path) | 995 | "#<module function %s from %s>", sym, path) |
| 994 | : sprintf (buffer, noaddr_format, env->subr)); | 996 | : sprintf (buffer, noaddr_format, env->subr)); |
| 995 | Lisp_Object unibyte_result = make_unibyte_string (buffer, size); | 997 | AUTO_STRING_WITH_LEN (unibyte_result, buffer, size); |
| 998 | Lisp_Object result = code_convert_string_norecord (unibyte_result, | ||
| 999 | Qutf_8, false); | ||
| 996 | if (buf != buffer) | 1000 | if (buf != buffer) |
| 997 | xfree (buf); | 1001 | xfree (buf); |
| 998 | return code_convert_string_norecord (unibyte_result, Qutf_8, false); | 1002 | return result; |
| 999 | } | 1003 | } |
| 1000 | 1004 | ||
| 1001 | 1005 | ||