emacs-diffs
[Top][All Lists]
Advanced

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

master add2b2d: Fix bug in recent allocate_string_data patch


From: Paul Eggert
Subject: master add2b2d: Fix bug in recent allocate_string_data patch
Date: Sat, 4 Jan 2020 16:34:11 -0500 (EST)

branch: master
commit add2b2da72babbc72134775499e14fc65da9bd44
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Fix bug in recent allocate_string_data patch
    
    Reported by Glenn Morris in:
    https://lists.gnu.org/r/emacs-devel/2020-01/msg00098.html
    * src/alloc.c (allocate_string_data): If the string is small and
    there is not enough room in the current block, clear the string if
    CLEARIT.
---
 src/alloc.c | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index d6d456a..7eb37bb 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -1831,26 +1831,27 @@ allocate_string_data (struct Lisp_String *s,
       b->next_free = data;
       large_sblocks = b;
     }
-  else if (current_sblock == NULL
-          || (((char *) current_sblock + SBLOCK_SIZE
-               - (char *) current_sblock->next_free)
-              < (needed + GC_STRING_EXTRA)))
-    {
-      /* Not enough room in the current sblock.  */
-      b = lisp_malloc (SBLOCK_SIZE, false, MEM_TYPE_NON_LISP);
-      data = b->data;
-      b->next = NULL;
-      b->next_free = data;
-
-      if (current_sblock)
-       current_sblock->next = b;
-      else
-       oldest_sblock = b;
-      current_sblock = b;
-    }
   else
     {
       b = current_sblock;
+
+      if (b == NULL
+         || (SBLOCK_SIZE - GC_STRING_EXTRA
+             < (char *) b->next_free - (char *) b + needed))
+       {
+         /* Not enough room in the current sblock.  */
+         b = lisp_malloc (SBLOCK_SIZE, false, MEM_TYPE_NON_LISP);
+         data = b->data;
+         b->next = NULL;
+         b->next_free = data;
+
+         if (current_sblock)
+           current_sblock->next = b;
+         else
+           oldest_sblock = b;
+         current_sblock = b;
+       }
+
       data = b->next_free;
       if (clearit)
        memset (SDATA_DATA (data), 0, nbytes);



reply via email to

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