emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 833a1f2c53: Fix thinko in last change


From: Po Lu
Subject: master 833a1f2c53: Fix thinko in last change
Date: Wed, 27 Jul 2022 08:02:06 -0400 (EDT)

branch: master
commit 833a1f2c53cf90e60f5ac37f634f6cc213263004
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    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)
---
 src/print.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/print.c b/src/print.c
index 6218c76224..384a639b31 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.  */
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]