emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r109651: Do not use memcpy for copyin


From: Dmitry Antipov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109651: Do not use memcpy for copying intervals.
Date: Fri, 17 Aug 2012 09:35:39 +0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109651
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Fri 2012-08-17 09:35:39 +0400
message:
  Do not use memcpy for copying intervals.
  * intervals.c (reproduce_interval): New function.
  (reproduce_tree, reproduce_tree_obj): Use it.
  (reproduce_tree_obj): Remove prototype.
modified:
  src/ChangeLog
  src/intervals.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-08-17 05:14:06 +0000
+++ b/src/ChangeLog     2012-08-17 05:35:39 +0000
@@ -1,3 +1,10 @@
+2012-08-17  Dmitry Antipov  <address@hidden>
+
+       Do not use memcpy for copying intervals.
+       * intervals.c (reproduce_interval): New function.
+       (reproduce_tree, reproduce_tree_obj): Use it.
+       (reproduce_tree_obj): Remove prototype.
+
 2012-08-17  Paul Eggert  <address@hidden>
 
        * lisp.h (duration_to_sec_usec): Remove unused decl.

=== modified file 'src/intervals.c'
--- a/src/intervals.c   2012-08-14 08:30:52 +0000
+++ b/src/intervals.c   2012-08-17 05:35:39 +0000
@@ -59,7 +59,6 @@
 static Lisp_Object merge_properties_sticky (Lisp_Object, Lisp_Object);
 static INTERVAL merge_interval_right (INTERVAL);
 static INTERVAL reproduce_tree (INTERVAL, INTERVAL);
-static INTERVAL reproduce_tree_obj (INTERVAL, Lisp_Object);
 
 /* Utility functions for intervals.  */
 
@@ -1498,6 +1497,26 @@
   abort ();
 }
 
+/* Create a copy of SOURCE but with the default value of UP.  */
+
+static INTERVAL
+reproduce_interval (INTERVAL source)
+{
+  register INTERVAL target = make_interval ();
+
+  target->total_length = source->total_length;
+  target->position = source->position;
+
+  copy_properties (source, target);
+
+  if (! NULL_LEFT_CHILD (source))
+    interval_set_left (target, reproduce_tree (source->left, target));
+  if (! NULL_RIGHT_CHILD (source))
+    interval_set_right (target, reproduce_tree (source->right, target));
+
+  return target;
+}
+
 /* Make an exact copy of interval tree SOURCE which descends from
    PARENT.  This is done by recursing through SOURCE, copying
    the current interval and its properties, and then adjusting
@@ -1506,33 +1525,19 @@
 static INTERVAL
 reproduce_tree (INTERVAL source, INTERVAL parent)
 {
-  register INTERVAL t = make_interval ();
-
-  memcpy (t, source, sizeof *t);
-  copy_properties (source, t);
-  interval_set_parent (t, parent);
-  if (! NULL_LEFT_CHILD (source))
-    interval_set_left (t, reproduce_tree (source->left, t));
-  if (! NULL_RIGHT_CHILD (source))
-    interval_set_right (t, reproduce_tree (source->right, t));
-
-  return t;
+  register INTERVAL target = reproduce_interval (source);
+
+  interval_set_parent (target, parent);
+  return target;
 }
 
 static INTERVAL
 reproduce_tree_obj (INTERVAL source, Lisp_Object parent)
 {
-  register INTERVAL t = make_interval ();
-
-  memcpy (t, source, sizeof *t);
-  copy_properties (source, t);
-  interval_set_object (t, parent);
-  if (! NULL_LEFT_CHILD (source))
-    interval_set_left (t, reproduce_tree (source->left, t));
-  if (! NULL_RIGHT_CHILD (source))
-    interval_set_right (t, reproduce_tree (source->right, t));
-
-  return t;
+  register INTERVAL target = reproduce_interval (source);
+
+  interval_set_object (target, parent);
+  return target;
 }
 
 /* Insert the intervals of SOURCE into BUFFER at POSITION.


reply via email to

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