aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Antipov2012-07-23 15:15:43 +0400
committerDmitry Antipov2012-07-23 15:15:43 +0400
commitd7a7fda3cc130edb8bc10af96d322d263afbb44a (patch)
treec7e8012e1b8ab313038ccd2dab1a2b39fa2c4bd6
parent5df1607869c5acff34382b5accf3332b1e72bc2a (diff)
downloademacs-d7a7fda3cc130edb8bc10af96d322d263afbb44a.tar.gz
emacs-d7a7fda3cc130edb8bc10af96d322d263afbb44a.zip
Cleanup miscellaneous objects allocation and initialization.
* alloc.c (allocate_misc): Change to static. Add argument to specify the subtype. Adjust comment and users. (build_overlay): New function. * buffer.c (copy_overlays, Fmake_overlay): Use it. * lisp.h (struct Lisp_Overlay): Remove obsolete comment. (allocate_misc): Remove prototype. (build_overlay): Add prototype.
-rw-r--r--src/ChangeLog13
-rw-r--r--src/alloc.c31
-rw-r--r--src/buffer.c15
-rw-r--r--src/lisp.h12
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 @@
12012-07-22 Dmitry Antipov <dmantipov@yandex.ru> 12012-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
122012-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
3565static union Lisp_Misc *marker_free_list; 3565static 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
3569Lisp_Object 3569static Lisp_Object
3570allocate_misc (void) 3570allocate_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
3639Lisp_Object
3640build_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
3637DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, 3652DEFUN ("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. */
1288struct Lisp_Overlay 1288struct 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);
2605extern Lisp_Object list4 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); 2595extern Lisp_Object list4 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
2606extern Lisp_Object list5 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, 2596extern Lisp_Object list5 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object,
2607 Lisp_Object); 2597 Lisp_Object);
2608extern Lisp_Object allocate_misc (void);
2609extern _Noreturn void string_overflow (void); 2598extern _Noreturn void string_overflow (void);
2610extern Lisp_Object make_string (const char *, ptrdiff_t); 2599extern Lisp_Object make_string (const char *, ptrdiff_t);
2611extern Lisp_Object make_formatted_string (char *, const char *, ...) 2600extern Lisp_Object make_formatted_string (char *, const char *, ...)
@@ -2667,6 +2656,7 @@ extern Lisp_Object make_float (double);
2667extern void display_malloc_warning (void); 2656extern void display_malloc_warning (void);
2668extern ptrdiff_t inhibit_garbage_collection (void); 2657extern ptrdiff_t inhibit_garbage_collection (void);
2669extern Lisp_Object make_save_value (void *, ptrdiff_t); 2658extern Lisp_Object make_save_value (void *, ptrdiff_t);
2659extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object);
2670extern void free_marker (Lisp_Object); 2660extern void free_marker (Lisp_Object);
2671extern void free_cons (struct Lisp_Cons *); 2661extern void free_cons (struct Lisp_Cons *);
2672extern void init_alloc_once (void); 2662extern void init_alloc_once (void);