From: Po Lu Date: Wed, 27 Jul 2022 11:56:43 +0000 (+0800) Subject: Fix thinko in last change X-Git-Tag: emacs-29.0.90~1447^2~725 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=833a1f2c53cf90e60f5ac37f634f6cc213263004;p=emacs.git 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) --- 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. */