summaryrefslogtreecommitdiff
path: root/src/print.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-07-27 19:56:43 +0800
committerPo Lu <luangruo@yahoo.com>2022-07-27 20:01:53 +0800
commit833a1f2c53cf90e60f5ac37f634f6cc213263004 (patch)
tree4a94a517c9536d3e761ca6355f87b06e713a9b40 /src/print.c
parente6b0fa4408c8e7b8bc6db70aeedbcbd235bdd7c3 (diff)
downloademacs-833a1f2c53cf90e60f5ac37f634f6cc213263004.tar.gz
emacs-833a1f2c53cf90e60f5ac37f634f6cc213263004.tar.bz2
emacs-833a1f2c53cf90e60f5ac37f634f6cc213263004.zip
Fix thinko in last change
* src/print.c (PRINTPREPARE): Also remove `print_free_buffer'. Record unwind protect instead. (PRINTFINISH): Stop freeing the print buffer. (bug#56773)
Diffstat (limited to 'src/print.c')
-rw-r--r--src/print.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/print.c b/src/print.c
index 6218c76224c..384a639b317 100644
--- a/src/print.c
+++ b/src/print.c
@@ -101,7 +101,6 @@ bool print_output_debug_flag EXTERNALLY_VISIBLE = 1;
ptrdiff_t old_point = -1, start_point = -1; \
ptrdiff_t old_point_byte = -1, start_point_byte = -1; \
specpdl_ref specpdl_count = SPECPDL_INDEX (); \
- bool free_print_buffer = 0; \
bool multibyte \
= !NILP (BVAR (current_buffer, enable_multibyte_characters)); \
Lisp_Object original = printcharfun; \
@@ -153,7 +152,7 @@ bool print_output_debug_flag EXTERNALLY_VISIBLE = 1;
int new_size = 1000; \
print_buffer = xmalloc (new_size); \
print_buffer_size = new_size; \
- free_print_buffer = 1; \
+ record_unwind_protect_void (print_free_buffer); \
} \
print_buffer_pos = 0; \
print_buffer_pos_byte = 0; \
@@ -180,11 +179,6 @@ bool print_output_debug_flag EXTERNALLY_VISIBLE = 1;
print_buffer_pos_byte, 0, 1, 0); \
signal_after_change (PT - print_buffer_pos, 0, print_buffer_pos);\
} \
- if (free_print_buffer) \
- { \
- xfree (print_buffer); \
- print_buffer = 0; \
- } \
unbind_to (specpdl_count, Qnil); \
if (MARKERP (original)) \
set_marker_both (original, Qnil, PT, PT_BYTE); \
@@ -194,6 +188,16 @@ bool print_output_debug_flag EXTERNALLY_VISIBLE = 1;
old_point_byte + (old_point_byte >= start_point_byte \
? PT_BYTE - start_point_byte : 0));
+/* This is used to free the print buffer; we don't simply record xfree
+ since print_buffer can be reallocated during the printing. */
+
+static void
+print_free_buffer (void)
+{
+ xfree (print_buffer);
+ print_buffer = NULL;
+}
+
/* This is used to restore the saved contents of print_buffer
when there is a recursive call to print. */