diff options
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/src/alloc.c b/src/alloc.c index 6b366485550..02c55f8ce4c 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -2864,50 +2864,57 @@ list3 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3) | |||
| 2864 | return Fcons (arg1, Fcons (arg2, Fcons (arg3, Qnil))); | 2864 | return Fcons (arg1, Fcons (arg2, Fcons (arg3, Qnil))); |
| 2865 | } | 2865 | } |
| 2866 | 2866 | ||
| 2867 | |||
| 2868 | Lisp_Object | 2867 | Lisp_Object |
| 2869 | list4 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, Lisp_Object arg4) | 2868 | list4 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, Lisp_Object arg4) |
| 2870 | { | 2869 | { |
| 2871 | return Fcons (arg1, Fcons (arg2, Fcons (arg3, Fcons (arg4, Qnil)))); | 2870 | return Fcons (arg1, Fcons (arg2, Fcons (arg3, Fcons (arg4, Qnil)))); |
| 2872 | } | 2871 | } |
| 2873 | 2872 | ||
| 2874 | |||
| 2875 | Lisp_Object | 2873 | Lisp_Object |
| 2876 | list5 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, Lisp_Object arg4, Lisp_Object arg5) | 2874 | list5 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, Lisp_Object arg4, |
| 2875 | Lisp_Object arg5) | ||
| 2877 | { | 2876 | { |
| 2878 | return Fcons (arg1, Fcons (arg2, Fcons (arg3, Fcons (arg4, | 2877 | return Fcons (arg1, Fcons (arg2, Fcons (arg3, Fcons (arg4, |
| 2879 | Fcons (arg5, Qnil))))); | 2878 | Fcons (arg5, Qnil))))); |
| 2880 | } | 2879 | } |
| 2881 | 2880 | ||
| 2882 | /* Make a list of COUNT Lisp_Objects, where ARG is the | 2881 | /* Make a list of COUNT Lisp_Objects, where ARG is the first one. |
| 2883 | first one. Allocate conses from pure space if TYPE | 2882 | Use CONS to construct the pairs. AP has any remaining args. */ |
| 2884 | is CONSTYPE_PURE, or allocate as usual if type is CONSTYPE_HEAP. */ | 2883 | static Lisp_Object |
| 2885 | 2884 | cons_listn (ptrdiff_t count, Lisp_Object arg, | |
| 2886 | Lisp_Object | 2885 | Lisp_Object (*cons) (Lisp_Object, Lisp_Object), va_list ap) |
| 2887 | listn (enum constype type, ptrdiff_t count, Lisp_Object arg, ...) | ||
| 2888 | { | 2886 | { |
| 2889 | Lisp_Object (*cons) (Lisp_Object, Lisp_Object); | ||
| 2890 | switch (type) | ||
| 2891 | { | ||
| 2892 | case CONSTYPE_PURE: cons = pure_cons; break; | ||
| 2893 | case CONSTYPE_HEAP: cons = Fcons; break; | ||
| 2894 | default: emacs_abort (); | ||
| 2895 | } | ||
| 2896 | |||
| 2897 | eassume (0 < count); | 2887 | eassume (0 < count); |
| 2898 | Lisp_Object val = cons (arg, Qnil); | 2888 | Lisp_Object val = cons (arg, Qnil); |
| 2899 | Lisp_Object tail = val; | 2889 | Lisp_Object tail = val; |
| 2900 | |||
| 2901 | va_list ap; | ||
| 2902 | va_start (ap, arg); | ||
| 2903 | for (ptrdiff_t i = 1; i < count; i++) | 2890 | for (ptrdiff_t i = 1; i < count; i++) |
| 2904 | { | 2891 | { |
| 2905 | Lisp_Object elem = cons (va_arg (ap, Lisp_Object), Qnil); | 2892 | Lisp_Object elem = cons (va_arg (ap, Lisp_Object), Qnil); |
| 2906 | XSETCDR (tail, elem); | 2893 | XSETCDR (tail, elem); |
| 2907 | tail = elem; | 2894 | tail = elem; |
| 2908 | } | 2895 | } |
| 2896 | return val; | ||
| 2897 | } | ||
| 2898 | |||
| 2899 | /* Make a list of COUNT Lisp_Objects, where ARG1 is the first one. */ | ||
| 2900 | Lisp_Object | ||
| 2901 | listn (ptrdiff_t count, Lisp_Object arg1, ...) | ||
| 2902 | { | ||
| 2903 | va_list ap; | ||
| 2904 | va_start (ap, arg1); | ||
| 2905 | Lisp_Object val = cons_listn (count, arg1, Fcons, ap); | ||
| 2909 | va_end (ap); | 2906 | va_end (ap); |
| 2907 | return val; | ||
| 2908 | } | ||
| 2910 | 2909 | ||
| 2910 | /* Make a pure list of COUNT Lisp_Objects, where ARG1 is the first one. */ | ||
| 2911 | Lisp_Object | ||
| 2912 | pure_listn (ptrdiff_t count, Lisp_Object arg1, ...) | ||
| 2913 | { | ||
| 2914 | va_list ap; | ||
| 2915 | va_start (ap, arg1); | ||
| 2916 | Lisp_Object val = cons_listn (count, arg1, pure_cons, ap); | ||
| 2917 | va_end (ap); | ||
| 2911 | return val; | 2918 | return val; |
| 2912 | } | 2919 | } |
| 2913 | 2920 | ||
| @@ -7283,8 +7290,7 @@ Frames, windows, buffers, and subprocesses count as vectors | |||
| 7283 | (but the contents of a buffer's text do not count here). */) | 7290 | (but the contents of a buffer's text do not count here). */) |
| 7284 | (void) | 7291 | (void) |
| 7285 | { | 7292 | { |
| 7286 | return listn (CONSTYPE_HEAP, 7, | 7293 | return list (make_int (cons_cells_consed), |
| 7287 | make_int (cons_cells_consed), | ||
| 7288 | make_int (floats_consed), | 7294 | make_int (floats_consed), |
| 7289 | make_int (vector_cells_consed), | 7295 | make_int (vector_cells_consed), |
| 7290 | make_int (symbols_consed), | 7296 | make_int (symbols_consed), |
| @@ -7584,8 +7590,10 @@ do hash-consing of the objects allocated to pure space. */); | |||
| 7584 | /* We build this in advance because if we wait until we need it, we might | 7590 | /* We build this in advance because if we wait until we need it, we might |
| 7585 | not be able to allocate the memory to hold it. */ | 7591 | not be able to allocate the memory to hold it. */ |
| 7586 | Vmemory_signal_data | 7592 | Vmemory_signal_data |
| 7587 | = listn (CONSTYPE_PURE, 2, Qerror, | 7593 | = pure_list (Qerror, |
| 7588 | build_pure_c_string ("Memory exhausted--use M-x save-some-buffers then exit and restart Emacs")); | 7594 | build_pure_c_string ("Memory exhausted--use" |
| 7595 | " M-x save-some-buffers then" | ||
| 7596 | " exit and restart Emacs")); | ||
| 7589 | 7597 | ||
| 7590 | DEFVAR_LISP ("memory-full", Vmemory_full, | 7598 | DEFVAR_LISP ("memory-full", Vmemory_full, |
| 7591 | doc: /* Non-nil means Emacs cannot get much more Lisp memory. */); | 7599 | doc: /* Non-nil means Emacs cannot get much more Lisp memory. */); |