diff options
| author | Dmitry Antipov | 2012-08-17 09:35:39 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-08-17 09:35:39 +0400 |
| commit | 44386687ef56cf67b8eaf34c3365fdcb6ff0aa3d (patch) | |
| tree | 628e65ccd2216925c89584a80a89967bddc7155e | |
| parent | 927c7216ad1efbcb0d1b0d2395e026f3ab13f70a (diff) | |
| download | emacs-44386687ef56cf67b8eaf34c3365fdcb6ff0aa3d.tar.gz emacs-44386687ef56cf67b8eaf34c3365fdcb6ff0aa3d.zip | |
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.
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/intervals.c | 47 |
2 files changed, 33 insertions, 21 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b1b6ac1cc4b..84d6920b3ea 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2012-08-17 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | Do not use memcpy for copying intervals. | ||
| 4 | * intervals.c (reproduce_interval): New function. | ||
| 5 | (reproduce_tree, reproduce_tree_obj): Use it. | ||
| 6 | (reproduce_tree_obj): Remove prototype. | ||
| 7 | |||
| 1 | 2012-08-17 Paul Eggert <eggert@cs.ucla.edu> | 8 | 2012-08-17 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 9 | ||
| 3 | * lisp.h (duration_to_sec_usec): Remove unused decl. | 10 | * lisp.h (duration_to_sec_usec): Remove unused decl. |
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/>. */ | |||
| 59 | static Lisp_Object merge_properties_sticky (Lisp_Object, Lisp_Object); | 59 | static Lisp_Object merge_properties_sticky (Lisp_Object, Lisp_Object); |
| 60 | static INTERVAL merge_interval_right (INTERVAL); | 60 | static INTERVAL merge_interval_right (INTERVAL); |
| 61 | static INTERVAL reproduce_tree (INTERVAL, INTERVAL); | 61 | static INTERVAL reproduce_tree (INTERVAL, INTERVAL); |
| 62 | static INTERVAL reproduce_tree_obj (INTERVAL, Lisp_Object); | ||
| 63 | 62 | ||
| 64 | /* Utility functions for intervals. */ | 63 | /* Utility functions for intervals. */ |
| 65 | 64 | ||
| @@ -1498,6 +1497,26 @@ merge_interval_left (register INTERVAL i) | |||
| 1498 | abort (); | 1497 | abort (); |
| 1499 | } | 1498 | } |
| 1500 | 1499 | ||
| 1500 | /* Create a copy of SOURCE but with the default value of UP. */ | ||
| 1501 | |||
| 1502 | static INTERVAL | ||
| 1503 | reproduce_interval (INTERVAL source) | ||
| 1504 | { | ||
| 1505 | register INTERVAL target = make_interval (); | ||
| 1506 | |||
| 1507 | target->total_length = source->total_length; | ||
| 1508 | target->position = source->position; | ||
| 1509 | |||
| 1510 | copy_properties (source, target); | ||
| 1511 | |||
| 1512 | if (! NULL_LEFT_CHILD (source)) | ||
| 1513 | interval_set_left (target, reproduce_tree (source->left, target)); | ||
| 1514 | if (! NULL_RIGHT_CHILD (source)) | ||
| 1515 | interval_set_right (target, reproduce_tree (source->right, target)); | ||
| 1516 | |||
| 1517 | return target; | ||
| 1518 | } | ||
| 1519 | |||
| 1501 | /* Make an exact copy of interval tree SOURCE which descends from | 1520 | /* Make an exact copy of interval tree SOURCE which descends from |
| 1502 | PARENT. This is done by recursing through SOURCE, copying | 1521 | PARENT. This is done by recursing through SOURCE, copying |
| 1503 | the current interval and its properties, and then adjusting | 1522 | the current interval and its properties, and then adjusting |
| @@ -1506,33 +1525,19 @@ merge_interval_left (register INTERVAL i) | |||
| 1506 | static INTERVAL | 1525 | static INTERVAL |
| 1507 | reproduce_tree (INTERVAL source, INTERVAL parent) | 1526 | reproduce_tree (INTERVAL source, INTERVAL parent) |
| 1508 | { | 1527 | { |
| 1509 | register INTERVAL t = make_interval (); | 1528 | register INTERVAL target = reproduce_interval (source); |
| 1510 | |||
| 1511 | memcpy (t, source, sizeof *t); | ||
| 1512 | copy_properties (source, t); | ||
| 1513 | interval_set_parent (t, parent); | ||
| 1514 | if (! NULL_LEFT_CHILD (source)) | ||
| 1515 | interval_set_left (t, reproduce_tree (source->left, t)); | ||
| 1516 | if (! NULL_RIGHT_CHILD (source)) | ||
| 1517 | interval_set_right (t, reproduce_tree (source->right, t)); | ||
| 1518 | 1529 | ||
| 1519 | return t; | 1530 | interval_set_parent (target, parent); |
| 1531 | return target; | ||
| 1520 | } | 1532 | } |
| 1521 | 1533 | ||
| 1522 | static INTERVAL | 1534 | static INTERVAL |
| 1523 | reproduce_tree_obj (INTERVAL source, Lisp_Object parent) | 1535 | reproduce_tree_obj (INTERVAL source, Lisp_Object parent) |
| 1524 | { | 1536 | { |
| 1525 | register INTERVAL t = make_interval (); | 1537 | register INTERVAL target = reproduce_interval (source); |
| 1526 | |||
| 1527 | memcpy (t, source, sizeof *t); | ||
| 1528 | copy_properties (source, t); | ||
| 1529 | interval_set_object (t, parent); | ||
| 1530 | if (! NULL_LEFT_CHILD (source)) | ||
| 1531 | interval_set_left (t, reproduce_tree (source->left, t)); | ||
| 1532 | if (! NULL_RIGHT_CHILD (source)) | ||
| 1533 | interval_set_right (t, reproduce_tree (source->right, t)); | ||
| 1534 | 1538 | ||
| 1535 | return t; | 1539 | interval_set_object (target, parent); |
| 1540 | return target; | ||
| 1536 | } | 1541 | } |
| 1537 | 1542 | ||
| 1538 | /* Insert the intervals of SOURCE into BUFFER at POSITION. | 1543 | /* Insert the intervals of SOURCE into BUFFER at POSITION. |