diff options
| -rw-r--r-- | src/ChangeLog | 13 | ||||
| -rw-r--r-- | src/alloc.c | 31 | ||||
| -rw-r--r-- | src/buffer.c | 15 | ||||
| -rw-r--r-- | src/lisp.h | 12 |
4 files changed, 38 insertions, 33 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index bc486a99bd4..fb25d8dc937 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,4 +1,15 @@ | |||
| 1 | 2012-07-22 Dmitry Antipov <dmantipov@yandex.ru> | 1 | 2012-07-23 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | |||
| 3 | Cleanup miscellaneous objects allocation and initialization. | ||
| 4 | * alloc.c (allocate_misc): Change to static. Add argument to | ||
| 5 | specify the subtype. Adjust comment and users. | ||
| 6 | (build_overlay): New function. | ||
| 7 | * buffer.c (copy_overlays, Fmake_overlay): Use it. | ||
| 8 | * lisp.h (struct Lisp_Overlay): Remove obsolete comment. | ||
| 9 | (allocate_misc): Remove prototype. | ||
| 10 | (build_overlay): Add prototype. | ||
| 11 | |||
| 12 | 2012-07-23 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | 13 | ||
| 3 | Swap buffer text indirection counters in Fbuffer_swap_text. | 14 | Swap buffer text indirection counters in Fbuffer_swap_text. |
| 4 | * buffer.c (Fbuffer_swap_text): Swap indirections too. | 15 | * buffer.c (Fbuffer_swap_text): Swap indirections too. |
diff --git a/src/alloc.c b/src/alloc.c index 9f3c2a2ed4b..d9c56b5c7c8 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -3564,10 +3564,10 @@ static int marker_block_index = MARKER_BLOCK_SIZE; | |||
| 3564 | 3564 | ||
| 3565 | static union Lisp_Misc *marker_free_list; | 3565 | static union Lisp_Misc *marker_free_list; |
| 3566 | 3566 | ||
| 3567 | /* Return a newly allocated Lisp_Misc object, with no substructure. */ | 3567 | /* Return a newly allocated Lisp_Misc object of specified TYPE. */ |
| 3568 | 3568 | ||
| 3569 | Lisp_Object | 3569 | static Lisp_Object |
| 3570 | allocate_misc (void) | 3570 | allocate_misc (enum Lisp_Misc_Type type) |
| 3571 | { | 3571 | { |
| 3572 | Lisp_Object val; | 3572 | Lisp_Object val; |
| 3573 | 3573 | ||
| @@ -3599,6 +3599,7 @@ allocate_misc (void) | |||
| 3599 | --total_free_markers; | 3599 | --total_free_markers; |
| 3600 | consing_since_gc += sizeof (union Lisp_Misc); | 3600 | consing_since_gc += sizeof (union Lisp_Misc); |
| 3601 | misc_objects_consed++; | 3601 | misc_objects_consed++; |
| 3602 | XMISCTYPE (val) = type; | ||
| 3602 | XMISCANY (val)->gcmarkbit = 0; | 3603 | XMISCANY (val)->gcmarkbit = 0; |
| 3603 | return val; | 3604 | return val; |
| 3604 | } | 3605 | } |
| @@ -3625,8 +3626,7 @@ make_save_value (void *pointer, ptrdiff_t integer) | |||
| 3625 | register Lisp_Object val; | 3626 | register Lisp_Object val; |
| 3626 | register struct Lisp_Save_Value *p; | 3627 | register struct Lisp_Save_Value *p; |
| 3627 | 3628 | ||
| 3628 | val = allocate_misc (); | 3629 | val = allocate_misc (Lisp_Misc_Save_Value); |
| 3629 | XMISCTYPE (val) = Lisp_Misc_Save_Value; | ||
| 3630 | p = XSAVE_VALUE (val); | 3630 | p = XSAVE_VALUE (val); |
| 3631 | p->pointer = pointer; | 3631 | p->pointer = pointer; |
| 3632 | p->integer = integer; | 3632 | p->integer = integer; |
| @@ -3634,6 +3634,21 @@ make_save_value (void *pointer, ptrdiff_t integer) | |||
| 3634 | return val; | 3634 | return val; |
| 3635 | } | 3635 | } |
| 3636 | 3636 | ||
| 3637 | /* Return a Lisp_Misc_Overlay object with specified START, END and PLIST. */ | ||
| 3638 | |||
| 3639 | Lisp_Object | ||
| 3640 | build_overlay (Lisp_Object start, Lisp_Object end, Lisp_Object plist) | ||
| 3641 | { | ||
| 3642 | register Lisp_Object overlay; | ||
| 3643 | |||
| 3644 | overlay = allocate_misc (Lisp_Misc_Overlay); | ||
| 3645 | OVERLAY_START (overlay) = start; | ||
| 3646 | OVERLAY_END (overlay) = end; | ||
| 3647 | OVERLAY_PLIST (overlay) = plist; | ||
| 3648 | XOVERLAY (overlay)->next = NULL; | ||
| 3649 | return overlay; | ||
| 3650 | } | ||
| 3651 | |||
| 3637 | DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, | 3652 | DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, |
| 3638 | doc: /* Return a newly allocated marker which does not point at any place. */) | 3653 | doc: /* Return a newly allocated marker which does not point at any place. */) |
| 3639 | (void) | 3654 | (void) |
| @@ -3641,8 +3656,7 @@ DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, | |||
| 3641 | register Lisp_Object val; | 3656 | register Lisp_Object val; |
| 3642 | register struct Lisp_Marker *p; | 3657 | register struct Lisp_Marker *p; |
| 3643 | 3658 | ||
| 3644 | val = allocate_misc (); | 3659 | val = allocate_misc (Lisp_Misc_Marker); |
| 3645 | XMISCTYPE (val) = Lisp_Misc_Marker; | ||
| 3646 | p = XMARKER (val); | 3660 | p = XMARKER (val); |
| 3647 | p->buffer = 0; | 3661 | p->buffer = 0; |
| 3648 | p->bytepos = 0; | 3662 | p->bytepos = 0; |
| @@ -3667,8 +3681,7 @@ build_marker (struct buffer *buf, ptrdiff_t charpos, ptrdiff_t bytepos) | |||
| 3667 | /* Every character is at least one byte. */ | 3681 | /* Every character is at least one byte. */ |
| 3668 | eassert (charpos <= bytepos); | 3682 | eassert (charpos <= bytepos); |
| 3669 | 3683 | ||
| 3670 | obj = allocate_misc (); | 3684 | obj = allocate_misc (Lisp_Misc_Marker); |
| 3671 | XMISCTYPE (obj) = Lisp_Misc_Marker; | ||
| 3672 | m = XMARKER (obj); | 3685 | m = XMARKER (obj); |
| 3673 | m->buffer = buf; | 3686 | m->buffer = buf; |
| 3674 | m->charpos = charpos; | 3687 | m->charpos = charpos; |
diff --git a/src/buffer.c b/src/buffer.c index 68208d17abe..734ddb5a1c1 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -433,12 +433,8 @@ copy_overlays (struct buffer *b, struct Lisp_Overlay *list) | |||
| 433 | XMARKER (end)->insertion_type | 433 | XMARKER (end)->insertion_type |
| 434 | = XMARKER (OVERLAY_END (old_overlay))->insertion_type; | 434 | = XMARKER (OVERLAY_END (old_overlay))->insertion_type; |
| 435 | 435 | ||
| 436 | overlay = allocate_misc (); | 436 | overlay = build_overlay |
| 437 | XMISCTYPE (overlay) = Lisp_Misc_Overlay; | 437 | (start, end, Fcopy_sequence (OVERLAY_PLIST (old_overlay))); |
| 438 | OVERLAY_START (overlay) = start; | ||
| 439 | OVERLAY_END (overlay) = end; | ||
| 440 | OVERLAY_PLIST (overlay) = Fcopy_sequence (OVERLAY_PLIST (old_overlay)); | ||
| 441 | XOVERLAY (overlay)->next = NULL; | ||
| 442 | 438 | ||
| 443 | if (tail) | 439 | if (tail) |
| 444 | tail = tail->next = XOVERLAY (overlay); | 440 | tail = tail->next = XOVERLAY (overlay); |
| @@ -3640,12 +3636,7 @@ for the rear of the overlay advance when text is inserted there | |||
| 3640 | if (!NILP (rear_advance)) | 3636 | if (!NILP (rear_advance)) |
| 3641 | XMARKER (end)->insertion_type = 1; | 3637 | XMARKER (end)->insertion_type = 1; |
| 3642 | 3638 | ||
| 3643 | overlay = allocate_misc (); | 3639 | overlay = build_overlay (beg, end, Qnil); |
| 3644 | XMISCTYPE (overlay) = Lisp_Misc_Overlay; | ||
| 3645 | XOVERLAY (overlay)->start = beg; | ||
| 3646 | XOVERLAY (overlay)->end = end; | ||
| 3647 | XOVERLAY (overlay)->plist = Qnil; | ||
| 3648 | XOVERLAY (overlay)->next = NULL; | ||
| 3649 | 3640 | ||
| 3650 | /* Put the new overlay on the wrong list. */ | 3641 | /* Put the new overlay on the wrong list. */ |
| 3651 | end = OVERLAY_END (overlay); | 3642 | end = OVERLAY_END (overlay); |
diff --git a/src/lisp.h b/src/lisp.h index 2f426c38fc5..e34a66af0c8 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1286,16 +1286,6 @@ struct Lisp_Marker | |||
| 1286 | /* START and END are markers in the overlay's buffer, and | 1286 | /* START and END are markers in the overlay's buffer, and |
| 1287 | PLIST is the overlay's property list. */ | 1287 | PLIST is the overlay's property list. */ |
| 1288 | struct Lisp_Overlay | 1288 | struct Lisp_Overlay |
| 1289 | /* An overlay's real data content is: | ||
| 1290 | - plist | ||
| 1291 | - buffer | ||
| 1292 | - insertion type of both ends | ||
| 1293 | - start & start_byte | ||
| 1294 | - end & end_byte | ||
| 1295 | - next (singly linked list of overlays). | ||
| 1296 | - start_next and end_next (singly linked list of markers). | ||
| 1297 | I.e. 9words plus 2 bits, 3words of which are for external linked lists. | ||
| 1298 | */ | ||
| 1299 | { | 1289 | { |
| 1300 | ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Overlay */ | 1290 | ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Overlay */ |
| 1301 | unsigned gcmarkbit : 1; | 1291 | unsigned gcmarkbit : 1; |
| @@ -2605,7 +2595,6 @@ extern Lisp_Object list3 (Lisp_Object, Lisp_Object, Lisp_Object); | |||
| 2605 | extern Lisp_Object list4 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); | 2595 | extern Lisp_Object list4 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); |
| 2606 | extern Lisp_Object list5 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, | 2596 | extern Lisp_Object list5 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, |
| 2607 | Lisp_Object); | 2597 | Lisp_Object); |
| 2608 | extern Lisp_Object allocate_misc (void); | ||
| 2609 | extern _Noreturn void string_overflow (void); | 2598 | extern _Noreturn void string_overflow (void); |
| 2610 | extern Lisp_Object make_string (const char *, ptrdiff_t); | 2599 | extern Lisp_Object make_string (const char *, ptrdiff_t); |
| 2611 | extern Lisp_Object make_formatted_string (char *, const char *, ...) | 2600 | extern Lisp_Object make_formatted_string (char *, const char *, ...) |
| @@ -2667,6 +2656,7 @@ extern Lisp_Object make_float (double); | |||
| 2667 | extern void display_malloc_warning (void); | 2656 | extern void display_malloc_warning (void); |
| 2668 | extern ptrdiff_t inhibit_garbage_collection (void); | 2657 | extern ptrdiff_t inhibit_garbage_collection (void); |
| 2669 | extern Lisp_Object make_save_value (void *, ptrdiff_t); | 2658 | extern Lisp_Object make_save_value (void *, ptrdiff_t); |
| 2659 | extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object); | ||
| 2670 | extern void free_marker (Lisp_Object); | 2660 | extern void free_marker (Lisp_Object); |
| 2671 | extern void free_cons (struct Lisp_Cons *); | 2661 | extern void free_cons (struct Lisp_Cons *); |
| 2672 | extern void init_alloc_once (void); | 2662 | extern void init_alloc_once (void); |