diff options
author | Dmitry Antipov <dmantipov@yandex.ru> | 2012-08-17 09:35:39 +0400 |
---|---|---|
committer | Dmitry Antipov <dmantipov@yandex.ru> | 2012-08-17 09:35:39 +0400 |
commit | 44386687ef56cf67b8eaf34c3365fdcb6ff0aa3d (patch) | |
tree | 628e65ccd2216925c89584a80a89967bddc7155e /src/intervals.c | |
parent | 927c7216ad1efbcb0d1b0d2395e026f3ab13f70a (diff) | |
download | emacs-44386687ef56cf67b8eaf34c3365fdcb6ff0aa3d.tar.gz |
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.
Diffstat (limited to 'src/intervals.c')
-rw-r--r-- | src/intervals.c | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/src/intervals.c b/src/intervals.c index 09949bbbd45..b0ef7c8d3b9 100644 --- a/src/intervals.c +++ b/src/intervals.c @@ -59,7 +59,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 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 @@ merge_interval_left (register INTERVAL i) 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 @@ merge_interval_left (register INTERVAL i) 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)); + register INTERVAL target = reproduce_interval (source); - return t; + 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)); + register INTERVAL target = reproduce_interval (source); - return t; + interval_set_object (target, parent); + return target; } /* Insert the intervals of SOURCE into BUFFER at POSITION. |