Backport: Really fix bug #11519, by fixing the last change in ralloc.c.
[bpt/emacs.git] / src / ralloc.c
index 13587b9..b1a5982 100644 (file)
@@ -636,7 +636,8 @@ resize_bloc (bloc_ptr bloc, SIZE size)
             }
          else
            {
-             memmove (b->new_data, b->data, b->size);
+             if (b->new_data != b->data)
+               memmove (b->new_data, b->data, b->size);
              *b->variable = b->data = b->new_data;
             }
        }
@@ -647,7 +648,8 @@ resize_bloc (bloc_ptr bloc, SIZE size)
        }
       else
        {
-         memmove (bloc->new_data, bloc->data, old_size);
+         if (bloc->new_data != bloc->data)
+           memmove (bloc->new_data, bloc->data, old_size);
          memset ((char *) bloc->new_data + old_size, 0, size - old_size);
          *bloc->variable = bloc->data = bloc->new_data;
        }
@@ -663,7 +665,8 @@ resize_bloc (bloc_ptr bloc, SIZE size)
             }
          else
            {
-             memmove (b->new_data, b->data, b->size);
+             if (b->new_data != b->data)
+               memmove (b->new_data, b->data, b->size);
              *b->variable = b->data = b->new_data;
            }
        }
@@ -754,7 +757,7 @@ r_alloc_sbrk (long int size)
   if (! r_alloc_initialized)
     r_alloc_init ();
 
-  if (! use_relocatable_buffers)
+  if (use_relocatable_buffers <= 0)
     return (*real_morecore) (size);
 
   if (size == 0)
@@ -816,7 +819,8 @@ r_alloc_sbrk (long int size)
             header.  */
          for (b = last_bloc; b != NIL_BLOC; b = b->prev)
            {
-             memmove (b->new_data, b->data, b->size);
+             if (b->new_data != b->data)
+               memmove (b->new_data, b->data, b->size);
              *b->variable = b->data = b->new_data;
            }
 
@@ -862,7 +866,8 @@ r_alloc_sbrk (long int size)
 
          for (b = first_bloc; b != NIL_BLOC; b = b->next)
            {
-             memmove (b->new_data, b->data, b->size);
+             if (b->new_data != b->data)
+               memmove (b->new_data, b->data, b->size);
              *b->variable = b->data = b->new_data;
            }
        }
@@ -1196,6 +1201,17 @@ r_alloc_reset_variable (POINTER *old, POINTER *new)
   bloc->variable = new;
 }
 
+void
+r_alloc_inhibit_buffer_relocation (int inhibit)
+{
+  if (use_relocatable_buffers > 1)
+    use_relocatable_buffers = 1;
+  if (inhibit)
+    use_relocatable_buffers--;
+  else if (use_relocatable_buffers < 1)
+    use_relocatable_buffers++;
+}
+
 \f
 /***********************************************************************
                            Initialization