Mercurial > emacs
comparison src/alloc.c @ 28269:fd13be8ae190
Changes towards better type safety regarding intervals, primarily
regarding the "parent" handle. These just separate out the different
usages based on the type of parent (interval vs lisp object); later
changes will do type checking and enforcement.
* intervals.h (NULL_INTERVAL): Cast to INTERVAL type.
(INT_LISPLIKE): New macro.
(NULL_INTERVAL_P): Use it.
(INTERVAL_HAS_PARENT, INTERVAL_HAS_OBJECT, SET_INTERVAL_PARENT,
SET_INTERVAL_OBJECT, INTERVAL_PARENT, COPY_INTERVAL_PARENT,
GET_INTERVAL_OBJECT, INTERVAL_PARENT_OR_NULL): New macros.
* alloc.c (make_interval, gc_sweep): Use new macros; eliminate all
explicit references to "parent" field of struct interval and
associated unclean type conversions.
* intervals.c (create_root_interval, root_interval, rotate_right,
rotate_left, balance_possible_root_interval, split_interval_right,
split_interval_left, interval_start_pos, find_interval,
next_interval, previous_interval, update_interval,
adjust_intervals_for_insertion, delete_node, delete_interval,
adjust_intervals_for_deletion, merge_interval_right,
merge_interval_left, reproduce_tree, graft_intervals_into_buffer,
copy_intervals_to_string): Likewise.
* intervals.h (AM_LEFT_CHILD, AM_RIGHT_CHILD, RESET_INTERVAL):
Likewise.
* syntax.c (update_syntax_table): Likewise.
* intervals.c (reproduce_tree_obj): New function, like
reproduce_tree but takes a Lisp_Object for the parent. Declare
with prototype.
(graft_intervals_into_buffer): Use it when appropriate.
(reproduce_tree): Declare with prototype.
(balance_possible_root_interval): Check that the parent is a lisp
object before trying to examine its type.
author | Ken Raeburn <raeburn@raeburn.org> |
---|---|
date | Wed, 22 Mar 2000 21:44:05 +0000 |
parents | 27014604bbd3 |
children | a72abbd8dc16 |
comparison
equal
deleted
inserted
replaced
28268:33f65d22f2a8 | 28269:fd13be8ae190 |
---|---|
709 INTERVAL val; | 709 INTERVAL val; |
710 | 710 |
711 if (interval_free_list) | 711 if (interval_free_list) |
712 { | 712 { |
713 val = interval_free_list; | 713 val = interval_free_list; |
714 interval_free_list = interval_free_list->parent; | 714 interval_free_list = INTERVAL_PARENT (interval_free_list); |
715 } | 715 } |
716 else | 716 else |
717 { | 717 { |
718 if (interval_block_index == INTERVAL_BLOCK_SIZE) | 718 if (interval_block_index == INTERVAL_BLOCK_SIZE) |
719 { | 719 { |
4213 | 4213 |
4214 for (i = 0; i < lim; i++) | 4214 for (i = 0; i < lim; i++) |
4215 { | 4215 { |
4216 if (! XMARKBIT (iblk->intervals[i].plist)) | 4216 if (! XMARKBIT (iblk->intervals[i].plist)) |
4217 { | 4217 { |
4218 iblk->intervals[i].parent = interval_free_list; | 4218 SET_INTERVAL_PARENT (&iblk->intervals[i], interval_free_list); |
4219 interval_free_list = &iblk->intervals[i]; | 4219 interval_free_list = &iblk->intervals[i]; |
4220 this_free++; | 4220 this_free++; |
4221 } | 4221 } |
4222 else | 4222 else |
4223 { | 4223 { |
4231 deallocate this block. */ | 4231 deallocate this block. */ |
4232 if (this_free == INTERVAL_BLOCK_SIZE && num_free > INTERVAL_BLOCK_SIZE) | 4232 if (this_free == INTERVAL_BLOCK_SIZE && num_free > INTERVAL_BLOCK_SIZE) |
4233 { | 4233 { |
4234 *iprev = iblk->next; | 4234 *iprev = iblk->next; |
4235 /* Unhook from the free list. */ | 4235 /* Unhook from the free list. */ |
4236 interval_free_list = iblk->intervals[0].parent; | 4236 interval_free_list = INTERVAL_PARENT (&iblk->intervals[0]); |
4237 lisp_free (iblk); | 4237 lisp_free (iblk); |
4238 n_interval_blocks--; | 4238 n_interval_blocks--; |
4239 } | 4239 } |
4240 else | 4240 else |
4241 { | 4241 { |