emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r109122: Restore old code in allocate


From: Dmitry Antipov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109122: Restore old code in allocate_string_data to avoid Faset breakage.
Date: Tue, 17 Jul 2012 16:31:29 +0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109122
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Tue 2012-07-17 16:31:29 +0400
message:
  Restore old code in allocate_string_data to avoid Faset breakage.
  Reported by Julien Danjou <address@hidden> in
  http://lists.gnu.org/archive/html/emacs-devel/2012-07/msg00371.html.
  * alloc.c (allocate_string_data): Restore old code with minor
  adjustments, fix comment to explain this subtle issue.
modified:
  src/ChangeLog
  src/alloc.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-07-17 11:52:00 +0000
+++ b/src/ChangeLog     2012-07-17 12:31:29 +0000
@@ -1,3 +1,11 @@
+2012-07-17  Dmitry Antipov  <address@hidden>
+
+       Restore old code in allocate_string_data to avoid Faset breakage.
+       Reported by Julien Danjou <address@hidden> in
+       http://lists.gnu.org/archive/html/emacs-devel/2012-07/msg00371.html.
+       * alloc.c (allocate_string_data): Restore old code with minor
+       adjustments, fix comment to explain this subtle issue.
+
 2012-07-17  Eli Zaretskii  <address@hidden>
 
        Remove FILE_SYSTEM_CASE.

=== modified file 'src/alloc.c'
--- a/src/alloc.c       2012-07-17 09:12:24 +0000
+++ b/src/alloc.c       2012-07-17 12:31:29 +0000
@@ -1971,9 +1971,9 @@
 allocate_string_data (struct Lisp_String *s,
                      EMACS_INT nchars, EMACS_INT nbytes)
 {
-  struct sdata *data;
+  struct sdata *data, *old_data;
   struct sblock *b;
-  ptrdiff_t needed;
+  ptrdiff_t needed, old_nbytes;
 
   if (STRING_BYTES_MAX < nbytes)
     string_overflow ();
@@ -1981,6 +1981,13 @@
   /* Determine the number of bytes needed to store NBYTES bytes
      of string data.  */
   needed = SDATA_SIZE (nbytes);
+  if (s->data)
+    {
+      old_data = SDATA_OF_STRING (s);
+      old_nbytes = GC_STRING_BYTES (s);
+    }
+  else
+    old_data = NULL;
 
   MALLOC_BLOCK_INPUT;
 
@@ -2050,6 +2057,16 @@
   memcpy ((char *) data + needed, string_overrun_cookie,
          GC_STRING_OVERRUN_COOKIE_SIZE);
 #endif
+
+  /* Note that Faset may call to this function when S has already data
+     assigned.  In this case, mark data as free by setting it's string
+     back-pointer to null, and record the size of the data in it.  */
+  if (old_data)
+    {
+      SDATA_NBYTES (old_data) = old_nbytes;
+      old_data->string = NULL;
+    }
+
   consing_since_gc += needed;
 }
 


reply via email to

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