Mercurial > hg > xemacs-beta
diff src/extents.c @ 185:3d6bfa290dbd r20-3b19
Import from CVS: tag r20-3b19
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:55:28 +0200 |
parents | e121b013d1f0 |
children | 489f57a838ef |
line wrap: on
line diff
--- a/src/extents.c Mon Aug 13 09:54:24 2007 +0200 +++ b/src/extents.c Mon Aug 13 09:55:28 2007 +0200 @@ -421,8 +421,6 @@ Lisp_Object Qextentp; Lisp_Object Qextent_live_p; -Lisp_Object Qend_closed; -Lisp_Object Qstart_open; Lisp_Object Qall_extents_closed; Lisp_Object Qall_extents_open; Lisp_Object Qall_extents_closed_open; @@ -546,8 +544,8 @@ a geometric progession that saves on realloc space. */ increment += 100 + ga->numels / 8; - ptr = xrealloc (ptr, - (ga->numels + ga->gapsize + increment)*ga->elsize); + ptr = (char *) xrealloc (ptr, + (ga->numels + ga->gapsize + increment)*ga->elsize); if (ptr == 0) memory_full (); ga->array = ptr; @@ -637,7 +635,7 @@ gap_array_marker_freelist = gap_array_marker_freelist->next; } else - m = (Gap_Array_Marker *) xmalloc (sizeof (*m)); + m = xnew (Gap_Array_Marker); m->pos = GAP_ARRAY_ARRAY_TO_MEMORY_POS (ga, pos); m->next = ga->markers; @@ -689,8 +687,7 @@ static Gap_Array * make_gap_array (int elsize) { - Gap_Array *ga = (Gap_Array *) xmalloc (sizeof(*ga)); - memset (ga, 0, sizeof(*ga)); + Gap_Array *ga = xnew_and_zero (Gap_Array); ga->elsize = elsize; return ga; } @@ -864,7 +861,7 @@ extent_list_marker_freelist = extent_list_marker_freelist->next; } else - m = (Extent_List_Marker *) xmalloc (sizeof (*m)); + m = xnew (Extent_List_Marker); m->m = gap_array_make_marker (endp ? el->end : el->start, pos); m->endp = endp; @@ -899,7 +896,7 @@ static Extent_List * allocate_extent_list (void) { - Extent_List *el = (Extent_List *) xmalloc (sizeof(*el)); + Extent_List *el = xnew (Extent_List); el->start = make_gap_array (sizeof(EXTENT)); el->end = make_gap_array (sizeof(EXTENT)); el->markers = 0; @@ -928,8 +925,7 @@ static Lisp_Object mark_extent_auxiliary (Lisp_Object obj, void (*markobj) (Lisp_Object)) { - struct extent_auxiliary *data = - (struct extent_auxiliary *) XEXTENT_AUXILIARY (obj); + struct extent_auxiliary *data = XEXTENT_AUXILIARY (obj); ((markobj) (data->begin_glyph)); ((markobj) (data->end_glyph)); ((markobj) (data->invisible)); @@ -944,8 +940,7 @@ { Lisp_Object extent_aux = Qnil; struct extent_auxiliary *data = - alloc_lcrecord (sizeof (struct extent_auxiliary), - lrecord_extent_auxiliary); + alloc_lcrecord_type (struct extent_auxiliary, lrecord_extent_auxiliary); copy_lcrecord (data, &extent_auxiliary_defaults); XSETEXTENT_AUXILIARY (extent_aux, data); @@ -1049,8 +1044,7 @@ { Lisp_Object extent_info = Qnil; struct extent_info *data = - alloc_lcrecord (sizeof (struct extent_info), - lrecord_extent_info); + alloc_lcrecord_type (struct extent_info, lrecord_extent_info); XSETEXTENT_INFO (extent_info, data); data->extents = allocate_extent_list (); @@ -1524,8 +1518,7 @@ static struct stack_of_extents * allocate_soe (void) { - struct stack_of_extents *soe = - malloc_type_and_zero (struct stack_of_extents); + struct stack_of_extents *soe = xnew_and_zero (struct stack_of_extents); soe->extents = allocate_extent_list (); soe->pos = -1; return soe; @@ -2364,7 +2357,7 @@ struct adjust_extents_for_deletion_arg { - extent_dynarr *list; + EXTENT_dynarr *list; }; static int @@ -2404,7 +2397,7 @@ #ifdef ERROR_CHECK_EXTENTS sledgehammer_extent_check (object); #endif - closure.list = (extent_dynarr *) Dynarr_new (EXTENT); + closure.list = Dynarr_new (EXTENT); /* We're going to be playing weird games below with extents and the SOE and such, so compute the list now of all the extents that we're going @@ -2600,15 +2593,13 @@ struct extent_fragment * extent_fragment_new (Lisp_Object buffer_or_string, struct frame *frm) { - struct extent_fragment *ef = (struct extent_fragment *) - xmalloc (sizeof (struct extent_fragment)); - - memset (ef, 0, sizeof (*ef)); + struct extent_fragment *ef = xnew_and_zero (struct extent_fragment); + ef->object = buffer_or_string; ef->frm = frm; ef->extents = Dynarr_new (EXTENT); - ef->begin_glyphs = Dynarr_new (struct glyph_block); - ef->end_glyphs = Dynarr_new (struct glyph_block); + ef->begin_glyphs = Dynarr_new (glyph_block); + ef->end_glyphs = Dynarr_new (glyph_block); return ef; } @@ -2633,7 +2624,7 @@ } static void -extent_fragment_sort_by_priority (extent_dynarr *extarr) +extent_fragment_sort_by_priority (EXTENT_dynarr *extarr) { int i; @@ -3037,16 +3028,16 @@ if (!EXTENT_LIVE_P (XEXTENT (obj))) error ("printing unreadable object #<destroyed extent>"); else - error ("printing unreadable object #<extent 0x%lx>", - (long)XEXTENT (obj)); + error ("printing unreadable object #<extent 0x%p>", + XEXTENT (obj)); } if (!EXTENT_LIVE_P (XEXTENT (obj))) write_c_string ("#<destroyed extent", printcharfun); else { - char *buf = alloca (strlen (title) + strlen (name) - + strlen (posttitle)); + char *buf = (char *) + alloca (strlen (title) + strlen (name) + strlen (posttitle) + 1); write_c_string ("#<extent ", printcharfun); print_extent_1 (obj, printcharfun, escapeflag); write_c_string (extent_detached_p (XEXTENT (obj)) @@ -3293,7 +3284,7 @@ Find next extent after EXTENT. If EXTENT is a buffer return the first extent in the buffer; likewise for strings. -Extents in a buffer are ordered in what is called the \"display\" +Extents in a buffer are ordered in what is called the "display" order, which sorts by increasing start positions and then by *decreasing* end positions. If you want to perform an operation on a series of extents, use @@ -3344,7 +3335,7 @@ #ifdef DEBUG_XEMACS DEFUN ("next-e-extent", Fnext_e_extent, 1, 1, 0, /* -Find next extent after EXTENT using the \"e\" order. +Find next extent after EXTENT using the "e" order. If EXTENT is a buffer return the first extent in the buffer; likewise for strings. */ @@ -3365,7 +3356,7 @@ } DEFUN ("previous-e-extent", Fprevious_e_extent, 1, 1, 0, /* -Find last extent before EXTENT using the \"e\" order. +Find last extent before EXTENT using the "e" order. If EXTENT is a buffer return the last extent in the buffer; likewise for strings. This function is analogous to `next-e-extent'. @@ -3428,7 +3419,7 @@ DEFUN ("extent-parent", Fextent_parent, 1, 1, 0, /* Return the parent (if any) of EXTENT. If an extent has a parent, it derives all its properties from that extent -and has no properties of its own. (The only \"properties\" that the +and has no properties of its own. (The only "properties" that the extent keeps are the buffer/string it refers to and the start and end points.) It is possible for an extent's parent to itself have a parent. */ @@ -3641,8 +3632,8 @@ this extent to share the same aux struct as the original one. */ struct extent_auxiliary *data = - alloc_lcrecord (sizeof (struct extent_auxiliary), - lrecord_extent_auxiliary); + alloc_lcrecord_type (struct extent_auxiliary, + lrecord_extent_auxiliary); copy_lcrecord (data, XEXTENT_AUXILIARY (XCAR (original->plist))); XSETEXTENT_AUXILIARY (XCAR (e->plist), data); @@ -4347,10 +4338,10 @@ } DEFUN ("extent-at", Fextent_at, 1, 5, 0, /* -Find \"smallest\" extent at POS in OBJECT having PROPERTY set. -Normally, an extent is \"at\" POS if it overlaps the region (POS, POS+1); +Find "smallest" extent at POS in OBJECT having PROPERTY set. +Normally, an extent is "at" POS if it overlaps the region (POS, POS+1); i.e. if it covers the character after POS. (However, see the definition - of AT-FLAG.) \"Smallest\" means the extent that comes last in the display + of AT-FLAG.) "Smallest" means the extent that comes last in the display order; this normally means the extent whose start position is closest to POS. See `next-extent' for more information. OBJECT specifies a buffer or string and defaults to the current buffer. @@ -5873,7 +5864,7 @@ Returns the value of the PROP property at the given position. Optional arg OBJECT specifies the buffer or string to look in, and defaults to the current buffer. -Optional arg AT-FLAG controls what it means for a property to be \"at\" +Optional arg AT-FLAG controls what it means for a property to be "at" a position, and has the same meaning as in `extent-at'. This examines only those properties added with `put-text-property'. See also `get-char-property'. @@ -5887,7 +5878,7 @@ Returns the value of the PROP property at the given position. Optional arg OBJECT specifies the buffer or string to look in, and defaults to the current buffer. -Optional arg AT-FLAG controls what it means for a property to be \"at\" +Optional arg AT-FLAG controls what it means for a property to be "at" a position, and has the same meaning as in `extent-at'. This examines properties on all extents. See also `get-text-property'.