Mercurial > hg > xemacs-beta
changeset 4967:0d4c9d0f6a8d
rewrite dynarr code
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-02-03 Ben Wing <ben@xemacs.org>
* device-x.c (x_get_resource_prefix):
* device-x.c (Fx_get_resource):
* device-x.c (Fx_get_resource_prefix):
* device-x.c (Fx_put_resource):
* dialog-msw.c:
* dialog-msw.c (handle_question_dialog_box):
* dired-msw.c (mswindows_sort_files):
* dired-msw.c (mswindows_get_files):
* extents.c (extent_fragment_sort_by_priority):
* extents.c (Fset_extent_parent):
* file-coding.c (coding_reader):
* file-coding.c (coding_writer):
* file-coding.c (gzip_convert):
* frame.c (generate_title_string):
* gutter.c (calculate_gutter_size_from_display_lines):
* indent.c (vmotion_1):
* lread.c (read_bit_vector):
* mule-coding.c (iso2022_decode):
* rangetab.c:
* rangetab.c (Fcopy_range_table):
* rangetab.c (Fget_range_table):
* rangetab.c (unified_range_table_copy_data):
* redisplay-msw.c (mswindows_output_string):
* redisplay-output.c (output_display_line):
* redisplay-output.c (redisplay_move_cursor):
* redisplay-output.c (redisplay_clear_bottom_of_window):
* redisplay-tty.c (tty_output_ichar_dynarr):
* redisplay-tty.c (set_foreground_to):
* redisplay-tty.c (set_background_to):
* redisplay-xlike-inc.c (XLIKE_output_string):
* redisplay.c (redisplay_window_text_width_string):
* redisplay.c (redisplay_text_width_string):
* redisplay.c (create_text_block):
* redisplay.c (SET_CURRENT_MODE_CHARS_PIXSIZE):
* redisplay.c (generate_fstring_runes):
* redisplay.c (regenerate_modeline):
* redisplay.c (ensure_modeline_generated):
* redisplay.c (real_current_modeline_height):
* redisplay.c (create_string_text_block):
* redisplay.c (regenerate_window):
* redisplay.c (REGEN_INC_FIND_START_END):
* redisplay.c (point_visible):
* redisplay.c (redisplay_window):
* redisplay.c (mark_glyph_block_dynarr):
* redisplay.c (line_start_cache_start):
* redisplay.c (start_with_line_at_pixpos):
* redisplay.c (update_line_start_cache):
* redisplay.c (glyph_to_pixel_translation):
* redisplay.c (pixel_to_glyph_translation):
* sysdep.c (qxe_readdir):
* text.c (dfc_convert_to_external_format):
* text.c (dfc_convert_to_internal_format):
* toolbar-common.c (common_output_toolbar_button):
* window.c (window_modeline_height):
* window.c (Fwindow_last_line_visible_height):
* window.c (window_displayed_height):
* window.c (window_scroll):
* window.c (get_current_pixel_pos):
Use Dynarr_begin() in place of Dynarr_atp (foo, 0).
* dynarr.c (Dynarr_realloc):
* dynarr.c (Dynarr_lisp_realloc):
* dynarr.c (Dynarr_resize):
* dynarr.c (Dynarr_insert_many):
* dynarr.c (Dynarr_delete_many):
* dynarr.c (Dynarr_memory_usage):
* dynarr.c (stack_like_malloc):
* dynarr.c (stack_like_free):
* lisp.h:
* lisp.h (DECLARE_DYNARR_LISP_IMP):
* lisp.h (XD_DYNARR_DESC):
* lisp.h (Dynarr_pop):
* gutter.c (output_gutter):
* redisplay-output.c (sync_rune_structs):
* redisplay-output.c (redisplay_output_window):
Redo the dynarr code, add greater checks.
Rename the `len', `largest' and `max' members to `len_',
`largest_' and `max_' to try and catch existing places that might
directly modify these values. Make new accessors Dynarr_largest()
and Dynarr_max() and make them and existing Dynarr_length() be
non-lvalues by adding '+ 0' to them; fix a couple of places in the
redisplay code that tried to modify the length directly by setting
Dynarr_length(). Use the accessors whenever possible even in the
dynarr code itself. The accessors also verify that 0 <= len <=
largest <= max. Rename settor function Dynarr_set_size() to
Dynarr_set_length() and use it more consistently; also create
lower-level Dynarr_set_length_1(). This latter function should be
the only function that directly modifies the `len_' member of a
Dynarr, and in the process makes sure that the `largest' value is
kept correct.
Consistently use ERROR_CHECK_STRUCTURES instead of
ERROR_CHECK_TYPES for error-checking code. Reintroduce the
temporarily disabled verification code on the positions of
Dynarr_at(), Dynarr_atp() and Dynarr_atp_past_end().
Also create Dynarr_resize_if() in place of a repeated
code fragment. Clean up all the functions that modify Dynarrs to
use the new macros and functions and verify the correctness of the
Dynarr both before and after the change.
Note that there are two kinds of verification -- one for accessing
and one for modifying. The difference is that the modify
verification additionally checks to make sure that the Dynarr
isn't locked. (This is used in redisplay to check for problems
with reentrancy.)
* lrecord.h: Move XD_DYNARR_DESC to lisp.h, grouping with the dynarr code.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Wed, 03 Feb 2010 20:51:18 -0600 |
parents | 48b63cd88a21 |
children | 4d35e52790f8 |
files | src/ChangeLog src/device-x.c src/dialog-msw.c src/dired-msw.c src/dynarr.c src/extents.c src/file-coding.c src/frame.c src/gutter.c src/indent.c src/lisp.h src/lread.c src/lrecord.h src/mule-ccl.c src/mule-coding.c src/rangetab.c src/redisplay-msw.c src/redisplay-output.c src/redisplay-tty.c src/redisplay-xlike-inc.c src/redisplay.c src/sysdep.c src/text.c src/toolbar-common.c src/window.c |
diffstat | 25 files changed, 453 insertions(+), 303 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Mon Feb 01 14:11:36 2010 -0600 +++ b/src/ChangeLog Wed Feb 03 20:51:18 2010 -0600 @@ -1,3 +1,114 @@ +2010-02-03 Ben Wing <ben@xemacs.org> + + * device-x.c (x_get_resource_prefix): + * device-x.c (Fx_get_resource): + * device-x.c (Fx_get_resource_prefix): + * device-x.c (Fx_put_resource): + * dialog-msw.c: + * dialog-msw.c (handle_question_dialog_box): + * dired-msw.c (mswindows_sort_files): + * dired-msw.c (mswindows_get_files): + * extents.c (extent_fragment_sort_by_priority): + * extents.c (Fset_extent_parent): + * file-coding.c (coding_reader): + * file-coding.c (coding_writer): + * file-coding.c (gzip_convert): + * frame.c (generate_title_string): + * gutter.c (calculate_gutter_size_from_display_lines): + * indent.c (vmotion_1): + * lread.c (read_bit_vector): + * mule-coding.c (iso2022_decode): + * rangetab.c: + * rangetab.c (Fcopy_range_table): + * rangetab.c (Fget_range_table): + * rangetab.c (unified_range_table_copy_data): + * redisplay-msw.c (mswindows_output_string): + * redisplay-output.c (output_display_line): + * redisplay-output.c (redisplay_move_cursor): + * redisplay-output.c (redisplay_clear_bottom_of_window): + * redisplay-tty.c (tty_output_ichar_dynarr): + * redisplay-tty.c (set_foreground_to): + * redisplay-tty.c (set_background_to): + * redisplay-xlike-inc.c (XLIKE_output_string): + * redisplay.c (redisplay_window_text_width_string): + * redisplay.c (redisplay_text_width_string): + * redisplay.c (create_text_block): + * redisplay.c (SET_CURRENT_MODE_CHARS_PIXSIZE): + * redisplay.c (generate_fstring_runes): + * redisplay.c (regenerate_modeline): + * redisplay.c (ensure_modeline_generated): + * redisplay.c (real_current_modeline_height): + * redisplay.c (create_string_text_block): + * redisplay.c (regenerate_window): + * redisplay.c (REGEN_INC_FIND_START_END): + * redisplay.c (point_visible): + * redisplay.c (redisplay_window): + * redisplay.c (mark_glyph_block_dynarr): + * redisplay.c (line_start_cache_start): + * redisplay.c (start_with_line_at_pixpos): + * redisplay.c (update_line_start_cache): + * redisplay.c (glyph_to_pixel_translation): + * redisplay.c (pixel_to_glyph_translation): + * sysdep.c (qxe_readdir): + * text.c (dfc_convert_to_external_format): + * text.c (dfc_convert_to_internal_format): + * toolbar-common.c (common_output_toolbar_button): + * window.c (window_modeline_height): + * window.c (Fwindow_last_line_visible_height): + * window.c (window_displayed_height): + * window.c (window_scroll): + * window.c (get_current_pixel_pos): + Use Dynarr_begin() in place of Dynarr_atp (foo, 0). + + * dynarr.c (Dynarr_realloc): + * dynarr.c (Dynarr_lisp_realloc): + * dynarr.c (Dynarr_resize): + * dynarr.c (Dynarr_insert_many): + * dynarr.c (Dynarr_delete_many): + * dynarr.c (Dynarr_memory_usage): + * dynarr.c (stack_like_malloc): + * dynarr.c (stack_like_free): + * lisp.h: + * lisp.h (DECLARE_DYNARR_LISP_IMP): + * lisp.h (XD_DYNARR_DESC): + * lisp.h (Dynarr_pop): + * gutter.c (output_gutter): + * redisplay-output.c (sync_rune_structs): + * redisplay-output.c (redisplay_output_window): + Redo the dynarr code, add greater checks. + + Rename the `len', `largest' and `max' members to `len_', + `largest_' and `max_' to try and catch existing places that might + directly modify these values. Make new accessors Dynarr_largest() + and Dynarr_max() and make them and existing Dynarr_length() be + non-lvalues by adding '+ 0' to them; fix a couple of places in the + redisplay code that tried to modify the length directly by setting + Dynarr_length(). Use the accessors whenever possible even in the + dynarr code itself. The accessors also verify that 0 <= len <= + largest <= max. Rename settor function Dynarr_set_size() to + Dynarr_set_length() and use it more consistently; also create + lower-level Dynarr_set_length_1(). This latter function should be + the only function that directly modifies the `len_' member of a + Dynarr, and in the process makes sure that the `largest' value is + kept correct. + + Consistently use ERROR_CHECK_STRUCTURES instead of + ERROR_CHECK_TYPES for error-checking code. Reintroduce the + temporarily disabled verification code on the positions of + Dynarr_at(), Dynarr_atp() and Dynarr_atp_past_end(). + Also create Dynarr_resize_if() in place of a repeated + code fragment. Clean up all the functions that modify Dynarrs to + use the new macros and functions and verify the correctness of the + Dynarr both before and after the change. + + Note that there are two kinds of verification -- one for accessing + and one for modifying. The difference is that the modify + verification additionally checks to make sure that the Dynarr + isn't locked. (This is used in redisplay to check for problems + with reentrancy.) + + * lrecord.h: Move XD_DYNARR_DESC to lisp.h, grouping with the dynarr code. + 2010-02-01 Aidan Kehoe <kehoea@parhasard.net> * fns.c (internal_equalp):
--- a/src/device-x.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/device-x.c Wed Feb 03 20:51:18 2010 -0600 @@ -1428,8 +1428,8 @@ class_len = strlen (appclass); Dynarr_add_many (name, appname, name_len); Dynarr_add_many (class_, appclass, class_len); - validify_resource_component (Dynarr_atp (name, 0), name_len); - validify_resource_component (Dynarr_atp (class_, 0), class_len); + validify_resource_component (Dynarr_begin (name), name_len); + validify_resource_component (Dynarr_begin (class_), class_len); } if (EQ (locale, Qglobal)) @@ -1571,8 +1571,8 @@ Dynarr_add (name_Extbyte_dynarr, '\0'); Dynarr_add (class_Extbyte_dynarr, '\0'); - name_string = Dynarr_atp (name_Extbyte_dynarr, 0); - class_string = Dynarr_atp (class_Extbyte_dynarr, 0); + name_string = Dynarr_begin (name_Extbyte_dynarr); + class_string = Dynarr_begin (class_Extbyte_dynarr); { XrmValue xrm_value; @@ -1671,9 +1671,9 @@ if (!display) return Qnil; - return Fcons (make_string ((Ibyte *) Dynarr_atp (name_Extbyte_dynarr, 0), + return Fcons (make_string ((Ibyte *) Dynarr_begin (name_Extbyte_dynarr), Dynarr_length (name_Extbyte_dynarr)), - make_string ((Ibyte *) Dynarr_atp (class_Extbyte_dynarr, 0), + make_string ((Ibyte *) Dynarr_begin (class_Extbyte_dynarr), Dynarr_length (class_Extbyte_dynarr))); }
--- a/src/dialog-msw.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/dialog-msw.c Wed Feb 03 20:51:18 2010 -0600 @@ -1,6 +1,6 @@ /* Implements elisp-programmable dialog boxes -- MS Windows interface. Copyright (C) 1998 Kirill M. Katsnelson <kkm@kis.ru> - Copyright (C) 2000, 2001, 2002, 2003, 2004 Ben Wing. + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2010 Ben Wing. This file is part of XEmacs. @@ -765,7 +765,7 @@ /* Woof! Everything is ready. Pop pop pop in now! */ did->hwnd = qxeCreateDialogIndirectParam (NULL, - (LPDLGTEMPLATE) Dynarr_atp (template_, 0), + (LPDLGTEMPLATE) Dynarr_begin (template_), FRAME_MSWINDOWS_HANDLE (f), dialog_proc, (LPARAM) LISP_TO_VOID (dialog_data)); if (!did->hwnd)
--- a/src/dired-msw.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/dired-msw.c Wed Feb 03 20:51:18 2010 -0600 @@ -179,7 +179,7 @@ { mswindows_sort_method = sort_by; mswindows_reverse_sort = reverse; - qsort (Dynarr_atp (files, 0), Dynarr_length (files), + qsort (Dynarr_begin (files), Dynarr_length (files), sizeof (Win32_file), mswindows_ls_sort_fcn); }
--- a/src/dynarr.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/dynarr.c Wed Feb 03 20:51:18 2010 -0600 @@ -157,7 +157,8 @@ { void *new_base = malloc (new_size * dy->elsize); memcpy (new_base, dy->base, - (dy->max < new_size ? dy->max : new_size) * dy->elsize); + (Dynarr_max (dy) < new_size ? Dynarr_max (dy) : new_size) * + dy->elsize); dy->base = new_base; } else @@ -186,7 +187,8 @@ void *new_base = alloc_lrecord_array (dy->elsize, new_size, dy->lisp_imp); if (dy->base) memcpy (new_base, dy->base, - (dy->max < new_size ? dy->max : new_size) * dy->elsize); + (Dynarr_max (dy) < new_size ? Dynarr_max (dy) : new_size) * + dy->elsize); dy->base = new_base; } @@ -210,16 +212,16 @@ double multiplier; Dynarr *dy = (Dynarr *) Dynarr_verify (d); - if (dy->max <= 8) + if (Dynarr_max (dy) <= 8) multiplier = 2; else multiplier = 1.5; - for (newsize = dy->max; newsize < size;) + for (newsize = Dynarr_max (dy); newsize < size;) newsize = max (Dynarr_min_size, (int) (multiplier * newsize)); /* Don't do anything if the array is already big enough. */ - if (newsize > dy->max) + if (newsize > Dynarr_max (dy)) { #ifdef NEW_GC if (dy->lisp_imp) @@ -229,7 +231,7 @@ #else /* not NEW_GC */ Dynarr_realloc (dy, newsize); #endif /* not NEW_GC */ - dy->max = newsize; + dy->max_ = newsize; } } @@ -237,47 +239,43 @@ void Dynarr_insert_many (void *d, const void *el, int len, int start) { - Dynarr *dy = (Dynarr *) Dynarr_verify (d); - - if (dy->len + len > dy->max) - Dynarr_resize (dy, dy->len + len); -#if 0 - /* WTF? We should be catching these problems. */ - /* Silently adjust start to be valid. */ - if (start > dy->len) - start = dy->len; - else if (start < 0) - start = 0; -#else + Dynarr *dy = Dynarr_verify_mod (d); + + Dynarr_resize_if (dy, len); + /* #### This could conceivably be wrong, if code wants to access stuff between len and largest. */ - type_checking_assert (start >= 0 && start <= dy->len); -#endif + structure_checking_assert (start >= 0 && start <= Dynarr_length (dy)); - if (start != dy->len) + if (start != Dynarr_length (dy)) { memmove ((char *) dy->base + (start + len)*dy->elsize, (char *) dy->base + start*dy->elsize, - (dy->len - start)*dy->elsize); + (Dynarr_length (dy) - start)*dy->elsize); } + /* Some functions call us with a value of 0 to mean "reserve space but + don't write into it" */ if (el) memcpy ((char *) dy->base + start*dy->elsize, el, len*dy->elsize); - dy->len += len; - if (dy->len > dy->largest) - dy->largest = dy->len; + Dynarr_set_length_1 (dy, Dynarr_length (dy) + len); + (void) Dynarr_verify_mod (dy); } void Dynarr_delete_many (void *d, int start, int len) { - Dynarr *dy = (Dynarr *) Dynarr_verify (d); + Dynarr *dy = Dynarr_verify_mod (d); - type_checking_assert (start >= 0 && len >= 0 && start + len <= dy->len); + structure_checking_assert (start >= 0 && len >= 0 && + start + len <= Dynarr_length (dy)); + memmove ((char *) dy->base + start*dy->elsize, (char *) dy->base + (start + len)*dy->elsize, - (dy->len - start - len)*dy->elsize); - dy->len -= len; + (Dynarr_length (dy) - start - len)*dy->elsize); + + Dynarr_set_length_1 (dy, Dynarr_length (dy) - len); + (void) Dynarr_verify_mod (dy); } void @@ -326,12 +324,13 @@ if (dy->base) { - Bytecount malloc_used = malloced_storage_size (dy->base, - dy->elsize * dy->max, 0); + Bytecount malloc_used = + malloced_storage_size (dy->base, dy->elsize * Dynarr_max (dy), 0); /* #### This may or may not be correct. Some Dynarrs would prefer that we use dy->len instead of dy->largest here. */ - Bytecount was_requested = dy->elsize * dy->largest; - Bytecount dynarr_overhead = dy->elsize * (dy->max - dy->largest); + Bytecount was_requested = dy->elsize * Dynarr_largest (dy); + Bytecount dynarr_overhead = + dy->elsize * (Dynarr_max (dy) - Dynarr_largest (dy)); total += malloc_used; stats->was_requested += was_requested; @@ -380,7 +379,7 @@ Dynarr_add (stack_like_in_use_list, this_one); Dynarr_reset (this_one); Dynarr_add_many (this_one, 0, size); - return Dynarr_atp (this_one, 0); + return Dynarr_begin (this_one); } void @@ -392,7 +391,7 @@ order, and the item at the end of the list will be the one we're looking for, so just check for this first and avoid any function calls. */ - if (Dynarr_atp (Dynarr_at (stack_like_in_use_list, len - 1), 0) == val) + if (Dynarr_begin (Dynarr_at (stack_like_in_use_list, len - 1)) == val) { char_dynarr *this_one = Dynarr_pop (stack_like_in_use_list); Dynarr_add (stack_like_free_list, this_one); @@ -403,7 +402,7 @@ int i; assert (len >= 2); for (i = len - 2; i >= 0; i--) - if (Dynarr_atp (Dynarr_at (stack_like_in_use_list, i), 0) == + if (Dynarr_begin (Dynarr_at (stack_like_in_use_list, i)) == val) { char_dynarr *this_one = Dynarr_at (stack_like_in_use_list, i);
--- a/src/extents.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/extents.c Wed Feb 03 20:51:18 2010 -0600 @@ -2971,7 +2971,7 @@ /* But some loser programs mess up and may create a large number of extents overlapping the same spot. This will result in catastrophic behavior if we use the bubble sort above. */ - qsort (Dynarr_atp (extarr, 0), Dynarr_length (extarr), + qsort (Dynarr_begin (extarr), Dynarr_length (extarr), sizeof (EXTENT), extent_priority_sort_function); } @@ -3884,14 +3884,14 @@ if (!NILP (parent)) extent_properties (XEXTENT (parent), newprops); - qsort (Dynarr_atp (oldprops, 0), Dynarr_length (oldprops), + qsort (Dynarr_begin (oldprops), Dynarr_length (oldprops), sizeof (Lisp_Object_pair), compare_key_value_pairs); - qsort (Dynarr_atp (newprops, 0), Dynarr_length (newprops), + qsort (Dynarr_begin (newprops), Dynarr_length (newprops), sizeof (Lisp_Object_pair), compare_key_value_pairs); orignewlength = Dynarr_length (newprops); for (i = 0; i < Dynarr_length (oldprops); i++) { - if (!bsearch (Dynarr_atp (oldprops, i), Dynarr_atp (newprops, 0), + if (!bsearch (Dynarr_atp (oldprops, i), Dynarr_begin (newprops), Dynarr_length (newprops), sizeof (Lisp_Object_pair), compare_key_value_pairs)) { @@ -3904,7 +3904,7 @@ for (i = 0; i < orignewlength; i++) { if (!Dynarr_length (oldprops) || !bsearch (Dynarr_atp (newprops, i), - Dynarr_atp (oldprops, 0), + Dynarr_begin (oldprops), Dynarr_length (oldprops), sizeof (Lisp_Object_pair), compare_key_value_pairs)) @@ -3915,9 +3915,9 @@ Dynarr_add (oldprops, new_); } } - qsort (Dynarr_atp (oldprops, 0), Dynarr_length (oldprops), + qsort (Dynarr_begin (oldprops), Dynarr_length (oldprops), sizeof (Lisp_Object_pair), compare_key_value_pairs); - qsort (Dynarr_atp (newprops, 0), Dynarr_length (newprops), + qsort (Dynarr_begin (newprops), Dynarr_length (newprops), sizeof (Lisp_Object_pair), compare_key_value_pairs); for (i = 0; i < Dynarr_length (oldprops); i++) {
--- a/src/file-coding.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/file-coding.c Wed Feb 03 20:51:18 2010 -0600 @@ -1835,7 +1835,7 @@ { Bytecount chunk = min (size, (Bytecount) Dynarr_length (str->convert_to)); - memcpy (data, Dynarr_atp (str->convert_to, 0), chunk); + memcpy (data, Dynarr_begin (str->convert_to), chunk); Dynarr_delete_many (str->convert_to, 0, chunk); data += chunk; size -= chunk; @@ -1864,7 +1864,7 @@ Dynarr_atp (str->convert_from, rejected), readmore); /* Trim size down to how much we actually got */ - Dynarr_set_size (str->convert_from, rejected + max (0, read_size)); + Dynarr_set_length (str->convert_from, rejected + max (0, read_size)); } if (read_size < 0) /* LSTREAM_ERROR */ @@ -1886,7 +1886,7 @@ /* Convert the data, and save any rejected data in convert_from */ processed = XCODESYSMETH (str->codesys, convert, - (str, Dynarr_atp (str->convert_from, 0), + (str, Dynarr_begin (str->convert_from), str->convert_to, to_process)); if (processed < 0) { @@ -1895,10 +1895,10 @@ } assert (processed <= to_process); if (processed < to_process) - memmove (Dynarr_atp (str->convert_from, 0), + memmove (Dynarr_begin (str->convert_from), Dynarr_atp (str->convert_from, processed), to_process - processed); - Dynarr_set_size (str->convert_from, to_process - processed); + Dynarr_set_length (str->convert_from, to_process - processed); } } @@ -1918,7 +1918,7 @@ Dynarr_reset (str->convert_to); size = XCODESYSMETH (str->codesys, convert, (str, data, str->convert_to, size)); - if (Lstream_write (str->other_end, Dynarr_atp (str->convert_to, 0), + if (Lstream_write (str->other_end, Dynarr_begin (str->convert_to), Dynarr_length (str->convert_to)) < 0) return -1; else @@ -4423,7 +4423,7 @@ data->stream.avail_out = reserved; zerr = inflate (&data->stream, Z_NO_FLUSH); /* Lop off the unused portion */ - Dynarr_set_size (dst, Dynarr_length (dst) - data->stream.avail_out); + Dynarr_set_length (dst, Dynarr_length (dst) - data->stream.avail_out); if (zerr != Z_OK) break; } @@ -4483,7 +4483,7 @@ deflate (&data->stream, str->eof ? Z_FINISH : Z_NO_FLUSH); /* Lop off the unused portion */ - Dynarr_set_size (dst, Dynarr_length (dst) - data->stream.avail_out); + Dynarr_set_length (dst, Dynarr_length (dst) - data->stream.avail_out); if (zerr != Z_OK) break; }
--- a/src/frame.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/frame.c Wed Feb 03 20:51:18 2010 -0600 @@ -3491,7 +3491,7 @@ return convert_ichar_string_into_malloced_string - (Dynarr_atp (title_string_ichar_dynarr, 0), + (Dynarr_begin (title_string_ichar_dynarr), Dynarr_length (title_string_ichar_dynarr), 0); }
--- a/src/gutter.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/gutter.c Wed Feb 03 20:51:18 2010 -0600 @@ -302,7 +302,7 @@ { dl = Dynarr_atp (ddla, Dynarr_length (ddla) - 1); size = (dl->ypos + dl->descent - dl->clip) - - (Dynarr_atp (ddla, 0)->ypos - Dynarr_atp (ddla, 0)->ascent); + - (Dynarr_begin (ddla)->ypos - Dynarr_begin (ddla)->ascent); } } /* For left and right we have to do some maths. */ @@ -450,7 +450,7 @@ /* If the number of display lines has shrunk, adjust. */ if (cdla_len > Dynarr_length (ddla)) { - Dynarr_length (cdla) = Dynarr_length (ddla); + Dynarr_set_length (cdla, Dynarr_length (ddla)); } /* grab coordinates of last line and blank after it. */
--- a/src/indent.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/indent.c Wed Feb 03 20:51:18 2010 -0600 @@ -663,7 +663,7 @@ if (ret_vpix) *ret_vpix = vpix_motion (w->line_start_cache, 0, elt); /* #### This should be BUF_BEGV (b), right? */ - return Dynarr_atp (w->line_start_cache, 0)->start; + return Dynarr_begin (w->line_start_cache)->start; } else {
--- a/src/lisp.h Mon Feb 01 14:11:36 2010 -0600 +++ b/src/lisp.h Wed Feb 03 20:51:18 2010 -0600 @@ -1697,71 +1697,64 @@ END_C_DECLS -/************************************************************************/ -/** Definitions of basic Lisp objects **/ +#include "lrecord.h" + /************************************************************************/ - -#include "lrecord.h" +/** Definitions of dynamic arrays (Dynarrs) and other allocators **/ +/************************************************************************/ BEGIN_C_DECLS -/* ------------------------ dynamic arrays ------------------- */ +/************* Dynarr declaration *************/ #ifdef NEW_GC +#define DECLARE_DYNARR_LISP_IMP() \ + const struct lrecord_implementation *lisp_imp; +#else +#define DECLARE_DYNARR_LISP_IMP() +#endif + #ifdef ERROR_CHECK_STRUCTURES -#define Dynarr_declare(type) \ - struct lrecord_header header; \ - type *base; \ - const struct lrecord_implementation *lisp_imp; \ - int locked; \ - int elsize; \ - int len; \ - int largest; \ - int max +#define DECLARE_DYNARR_LOCKED() \ + int locked; #else -#define Dynarr_declare(type) \ - struct lrecord_header header; \ - type *base; \ - const struct lrecord_implementation *lisp_imp; \ - int elsize; \ - int len; \ - int largest; \ - int max -#endif /* ERROR_CHECK_STRUCTURES */ -#else /* not NEW_GC */ -#ifdef ERROR_CHECK_STRUCTURES -#define Dynarr_declare(type) \ - struct lrecord_header header; \ - type *base; \ - int locked; \ - int elsize; \ - int len; \ - int largest; \ - int max -#else -#define Dynarr_declare(type) \ - struct lrecord_header header; \ - type *base; \ - int elsize; \ - int len; \ - int largest; \ - int max -#endif /* ERROR_CHECK_STRUCTURES */ -#endif /* not NEW_GC */ +#define DECLARE_DYNARR_LOCKED() +#endif + +#define Dynarr_declare(type) \ + struct lrecord_header header; \ + type *base; \ + DECLARE_DYNARR_LISP_IMP () \ + DECLARE_DYNARR_LOCKED () \ + int elsize; \ + int len_; \ + int largest_; \ + int max_ typedef struct dynarr { Dynarr_declare (void); } Dynarr; -MODULE_API void *Dynarr_newf (int elsize); -MODULE_API void Dynarr_resize (void *dy, Elemcount size); -MODULE_API void Dynarr_insert_many (void *d, const void *el, int len, - int start); -MODULE_API void Dynarr_delete_many (void *d, int start, int len); -MODULE_API void Dynarr_free (void *d); - -#ifdef ERROR_CHECK_TYPES +#define XD_DYNARR_DESC(base_type, sub_desc) \ + { XD_BLOCK_PTR, offsetof (base_type, base), \ + XD_INDIRECT(1, 0), {sub_desc} }, \ + { XD_INT, offsetof (base_type, len_) }, \ + { XD_INT_RESET, offsetof (base_type, largest_), XD_INDIRECT(1, 0) }, \ + { XD_INT_RESET, offsetof (base_type, max_), XD_INDIRECT(1, 0) } + +#ifdef NEW_GC +#define XD_LISP_DYNARR_DESC(base_type, sub_desc) \ + { XD_LISP_OBJECT_BLOCK_PTR, offsetof (base_type, base), \ + XD_INDIRECT(1, 0), {sub_desc} }, \ + { XD_INT, offsetof (base_type, len_) }, \ + { XD_INT_RESET, offsetof (base_type, largest_), XD_INDIRECT(1, 0) }, \ + { XD_INT_RESET, offsetof (base_type, max_), XD_INDIRECT(1, 0) } +#endif /* NEW_GC */ + +/************* Dynarr verification *************/ + +#ifdef ERROR_CHECK_STRUCTURES DECLARE_INLINE_HEADER ( int Dynarr_verify_pos_at (void *d, int pos, const Ascbyte *file, int line) @@ -1770,7 +1763,7 @@ Dynarr *dy = (Dynarr *) d; /* We use `largest', not `len', because the redisplay code often accesses stuff between len and largest. */ - assert_at_line (pos >= 0 && pos < dy->largest, file, line); + assert_at_line (pos >= 0 && pos < dy->largest_, file, line); return pos; } @@ -1793,7 +1786,7 @@ hence the return value is NULL. But the length of 0 causes the pointer to never get checked. These can occur throughout the code so we put in a special check. */ - if (pos == 0 && dy->len == 0) + if (pos == 0 && dy->len_ == 0) return pos; /* #### It's vaguely possible that some code could legitimately want to retrieve a pointer to the position just past the end of dynarr memory. @@ -1806,7 +1799,7 @@ memory, which is a likely off-by-one problem to occur and will usually not trigger a protection fault (instead, you'll just get random behavior, possibly overwriting other memory, which is bad). */ - assert_at_line (pos >= 0 && pos < dy->largest, file, line); + assert_at_line (pos >= 0 && pos < dy->largest_, file, line); return pos; } @@ -1821,7 +1814,7 @@ accesses stuff between len and largest. We also allow referencing the very end, past the end of allocated legitimately space. See comments in Dynarr_verify_pos_atp.()*/ - assert_at_line (pos >= 0 && pos <= dy->largest, file, line); + assert_at_line (pos >= 0 && pos <= dy->largest_, file, line); return pos; } @@ -1829,7 +1822,53 @@ #define Dynarr_verify_pos_at(d, pos, file, line) (pos) #define Dynarr_verify_pos_atp(d, pos, file, line) (pos) #define Dynarr_verify_pos_atp_allow_end(d, pos, file, line) (pos) -#endif /* ERROR_CHECK_TYPES */ +#endif /* ERROR_CHECK_STRUCTURES */ + +#ifdef ERROR_CHECK_STRUCTURES +DECLARE_INLINE_HEADER ( +Dynarr * +Dynarr_verify_1 (void *d, const Ascbyte *file, int line) +) +{ + Dynarr *dy = (Dynarr *) d; + assert_at_line (dy->len_ >= 0 && dy->len_ <= dy->largest_ && + dy->largest_ <= dy->max_, file, line); + return dy; +} + +DECLARE_INLINE_HEADER ( +Dynarr * +Dynarr_verify_mod_1 (void *d, const Ascbyte *file, int line) +) +{ + Dynarr *dy = (Dynarr *) d; + assert_at_line (!dy->locked, file, line); + return Dynarr_verify_1 (d, file, line); +} + +#define Dynarr_verify(d) Dynarr_verify_1 (d, __FILE__, __LINE__) +#define Dynarr_verify_mod(d) Dynarr_verify_mod_1 (d, __FILE__, __LINE__) +#define Dynarr_lock(d) \ +do { \ + Dynarr *dy = Dynarr_verify_mod (d); \ + dy->locked = 1; \ +} while (0) +#define Dynarr_unlock(d) \ +do { \ + Dynarr *dy = Dynarr_verify (d); \ + dy->locked = 0; \ +} while (0) +#else +#define Dynarr_verify(d) (d) +#define Dynarr_verify_mod(d) (d) +#define Dynarr_lock(d) DO_NOTHING +#define Dynarr_unlock(d) DO_NOTHING +#endif /* ERROR_CHECK_STRUCTURES */ + +/************* Dynarr creation *************/ + +MODULE_API void *Dynarr_newf (int elsize); +MODULE_API void Dynarr_free (void *d); #ifdef NEW_GC MODULE_API void *Dynarr_lisp_newf (int elsize, @@ -1846,7 +1885,9 @@ #define Dynarr_new2(dynarr_type, type) \ ((dynarr_type *) Dynarr_newf (sizeof (type))) -#ifdef ERROR_CHECK_TYPES_GCC_NOT_BROKEN +/************* Dynarr access *************/ + +#ifdef ERROR_CHECK_STRUCTURES /* Enabling this leads to crashes in Cygwin 1.7, gcc 3.4.4 */ #define Dynarr_at(d, pos) \ ((d)->base[Dynarr_verify_pos_at (d, pos, __FILE__, __LINE__)]) @@ -1864,46 +1905,97 @@ #define Dynarr_begin(d) Dynarr_atp (d, 0) #define Dynarr_lastp(d) Dynarr_atp (d, Dynarr_length (d) - 1) #define Dynarr_past_lastp(d) Dynarr_atp_allow_end (d, Dynarr_length (d)) -#define Dynarr_sizeof(d) ((d)->len * (d)->elsize) - -#ifdef ERROR_CHECK_STRUCTURES -DECLARE_INLINE_HEADER ( -Dynarr * -Dynarr_verify_1 (void *d, const Ascbyte *file, int line) -) -{ - Dynarr *dy = (Dynarr *) d; - assert_at_line (dy->len >= 0 && dy->len <= dy->largest && - dy->largest <= dy->max, file, line); - return dy; -} - -DECLARE_INLINE_HEADER ( -Dynarr * -Dynarr_verify_mod_1 (void *d, const Ascbyte *file, int line) -) -{ - Dynarr *dy = (Dynarr *) d; - assert_at_line (!dy->locked, file, line); - assert_at_line (dy->len >= 0 && dy->len <= dy->largest && - dy->largest <= dy->max, file, line); - return dy; -} - -#define Dynarr_verify(d) Dynarr_verify_1 (d, __FILE__, __LINE__) -#define Dynarr_verify_mod(d) Dynarr_verify_mod_1 (d, __FILE__, __LINE__) -#define Dynarr_lock(d) (Dynarr_verify_mod (d)->locked = 1) -#define Dynarr_unlock(d) ((d)->locked = 0) -#else -#define Dynarr_verify(d) (d) -#define Dynarr_verify_mod(d) (d) -#define Dynarr_lock(d) -#define Dynarr_unlock(d) -#endif /* ERROR_CHECK_STRUCTURES */ - -#define Dynarr_length(d) (Dynarr_verify (d)->len) -#define Dynarr_largest(d) (Dynarr_verify (d)->largest) -#define Dynarr_reset(d) (Dynarr_verify_mod (d)->len = 0) + + +/************* Dynarr length/size retrieval and setting *************/ + +/* Retrieve the length of a Dynarr. The `+ 0' is to ensure that this cannot + be used as an lvalue. */ +#define Dynarr_length(d) (Dynarr_verify (d)->len_ + 0) +/* Retrieve the largest ever length seen of a Dynarr. The `+ 0' is to + ensure that this cannot be used as an lvalue. */ +#define Dynarr_largest(d) (Dynarr_verify (d)->largest_ + 0) +/* Retrieve the number of elements that fit in the currently allocated + space. The `+ 0' is to ensure that this cannot be used as an lvalue. */ +#define Dynarr_max(d) (Dynarr_verify (d)->max_ + 0) +/* Retrieve the advertised memory usage of a Dynarr, i.e. the number of + bytes occupied by the elements in the Dynarr, not counting any overhead. */ +#define Dynarr_sizeof(d) (Dynarr_length (d) * (d)->elsize) +/* Actually set the length of a Dynarr. This is a low-level routine that + should not be directly used; use Dynarr_set_length() instead if you need + to, but be very careful when doing so! */ +#define Dynarr_set_length_1(d, n) \ +do { \ + Elemcount _dsl1_n = (n); \ + structure_checking_assert (_dsl1_n >= 0 && _dsl1_n <= Dynarr_max (d)); \ + (void) Dynarr_verify_mod (d); \ + (d)->len_ = _dsl1_n; \ + /* Use the raw field references here otherwise we get a crash because \ + we've set the length but not yet fixed up the largest value. */ \ + if ((d)->len_ > (d)->largest_) \ + (d)->largest_ = (d)->len_; \ + (void) Dynarr_verify_mod (d); \ +} while (0) + +/* The following two defines will get you into real trouble if you aren't + careful. But they can save a lot of execution time when used wisely. */ +#define Dynarr_set_length(d, n) \ +do { \ + Elemcount _dsl_n = (n); \ + structure_checking_assert (_dsl_n >= 0 && _dsl_n <= Dynarr_largest (d)); \ + Dynarr_set_length_1 (d, _dsl_n); \ +} while (0) +#define Dynarr_increment(d) \ + Dynarr_set_length (d, Dynarr_length (d) + 1) + +/* Reset the Dynarr's length to 0. */ +#define Dynarr_reset(d) Dynarr_set_length (d, 0) + +MODULE_API void Dynarr_resize (void *dy, Elemcount size); + +#define Dynarr_resize_if(d, numels) \ +do { \ + Elemcount _dri_numels = (numels); \ + if (Dynarr_length (d) + _dri_numels > Dynarr_max (d)) \ + Dynarr_resize (d, Dynarr_length (d) + _dri_numels); \ +} while (0) + +#ifdef MEMORY_USAGE_STATS +struct overhead_stats; +Bytecount Dynarr_memory_usage (void *d, struct overhead_stats *stats); +#endif + +/************* Adding/deleting elements to/from a Dynarr *************/ + +#ifdef NEW_GC +#define Dynarr_add(d, el) \ +do { \ + const struct lrecord_implementation *imp = (d)->lisp_imp; \ + (void) Dynarr_verify_mod (d); \ + Dynarr_resize_if (d, 1); \ + ((d)->base)[Dynarr_length (d)] = (el); \ + if (imp) \ + set_lheader_implementation \ + ((struct lrecord_header *)&(((d)->base)[Dynarr_length (d)]), imp); \ + Dynarr_set_length_1 (d, Dynarr_length (d) + 1); \ + (void) Dynarr_verify_mod (d); \ +} while (0) +#else /* not NEW_GC */ +#define Dynarr_add(d, el) \ +do { \ + (void) Dynarr_verify_mod (d); \ + Dynarr_resize_if (d, 1); \ + ((d)->base)[Dynarr_length (d)] = (el); \ + Dynarr_set_length_1 (d, Dynarr_length (d) + 1); \ + (void) Dynarr_verify_mod (d); \ +} while (0) +#endif /* not NEW_GC */ + + +MODULE_API void Dynarr_insert_many (void *d, const void *el, int len, + int start); +MODULE_API void Dynarr_delete_many (void *d, int start, int len); + #define Dynarr_insert_many_at_start(d, el, len) \ Dynarr_insert_many (d, el, len, 0) #define Dynarr_add_literal_string(d, s) Dynarr_add_many (d, s, sizeof (s) - 1) @@ -1919,30 +2011,6 @@ Dynarr_add_many (d, dyna_ls_eb, dyna_ls_bc); \ } while (0) -#ifdef NEW_GC -#define Dynarr_add(d, el) \ -do { \ - const struct lrecord_implementation *imp = (d)->lisp_imp; \ - if (Dynarr_verify_mod (d)->len >= (d)->max) \ - Dynarr_resize ((d), (d)->len+1); \ - ((d)->base)[(d)->len] = (el); \ - \ - if (imp) \ - set_lheader_implementation \ - ((struct lrecord_header *)&(((d)->base)[(d)->len]), imp); \ - \ - (d)->len++; \ - if ((d)->len > (d)->largest) \ - (d)->largest = (d)->len; \ -} while (0) -#else /* not NEW_GC */ -#define Dynarr_add(d, el) ( \ - Dynarr_verify_mod (d)->len >= (d)->max ? Dynarr_resize ((d), (d)->len+1) : \ - (void) 0, \ - ((d)->base)[(d)->len++] = (el), \ - (d)->len > (d)->largest ? (d)->largest = (d)->len : (int) 0) -#endif /* not NEW_GC */ - /* Add LEN contiguous elements to a Dynarr */ DECLARE_INLINE_HEADER ( @@ -1953,33 +2021,20 @@ /* This duplicates Dynarr_insert_many to some extent; but since it is called so often, it seemed useful to remove the unnecessary stuff from that function and to make it inline */ - Dynarr *dy = (Dynarr *) Dynarr_verify (d); - - if (dy->len + len > dy->max) - Dynarr_resize (dy, dy->len + len); + Dynarr *dy = Dynarr_verify_mod (d); + Dynarr_resize_if (dy, len); /* Some functions call us with a value of 0 to mean "reserve space but don't write into it" */ if (el) - memcpy ((char *) dy->base + dy->len*dy->elsize, el, len*dy->elsize); - dy->len += len; - - if (dy->len > dy->largest) - dy->largest = dy->len; + memcpy ((char *) dy->base + Dynarr_sizeof (dy), el, len*dy->elsize); + Dynarr_set_length_1 (dy, Dynarr_length (dy) + len); + (void) Dynarr_verify_mod (dy); } -/* The following defines will get you into real trouble if you aren't - careful. But they can save a lot of execution time when used wisely. */ -#define Dynarr_increment(d) (Dynarr_verify_mod (d)->len++) -#define Dynarr_set_size(d, n) \ -do { \ - Bytecount _dss_n = (n); \ - structure_checking_assert (_dss_n >= 0 && _dss_n <= (d)->largest); \ - Dynarr_verify_mod (d)->len = _dss_n; \ -} while (0) - #define Dynarr_pop(d) \ - (assert ((d)->len > 0), Dynarr_verify_mod (d)->len--, \ - Dynarr_at (d, (d)->len)) + (structure_checking_assert (Dynarr_length (d) > 0), \ + Dynarr_verify_mod (d)->len_--, \ + Dynarr_at (d, Dynarr_length (d))) #define Dynarr_delete(d, i) Dynarr_delete_many (d, i, 1) #define Dynarr_delete_by_pointer(d, p) \ Dynarr_delete_many (d, (p) - ((d)->base), 1) @@ -1995,17 +2050,7 @@ } \ } while (0) -#ifdef MEMORY_USAGE_STATS -struct overhead_stats; -Bytecount Dynarr_memory_usage (void *d, struct overhead_stats *stats); -#endif - -void *stack_like_malloc (Bytecount size); -void stack_like_free (void *val); - -/* ------------------------------- */ -/* Dynarr typedefs */ -/* ------------------------------- */ +/************* Dynarr typedefs *************/ /* Dynarr typedefs -- basic types first */ @@ -2130,6 +2175,17 @@ Dynarr_declare (Lisp_Object *); } Lisp_Object_ptr_dynarr; + +/************* Stack-like malloc/free: Another allocator *************/ + +void *stack_like_malloc (Bytecount size); +void stack_like_free (void *val); + + +/************************************************************************/ +/** Definitions of other basic Lisp objects **/ +/************************************************************************/ + /*------------------------------ unbound -------------------------------*/ /* Qunbound is a special Lisp_Object (actually of type
--- a/src/lread.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/lread.c Wed Feb 03 20:51:18 2010 -0600 @@ -2129,7 +2129,7 @@ Dynarr_add (dyn, bit); } - val = make_bit_vector_from_byte_vector (Dynarr_atp (dyn, 0), + val = make_bit_vector_from_byte_vector (Dynarr_begin (dyn), Dynarr_length (dyn)); Dynarr_free (dyn);
--- a/src/lrecord.h Mon Feb 01 14:11:36 2010 -0600 +++ b/src/lrecord.h Wed Feb 03 20:51:18 2010 -0600 @@ -1143,22 +1143,6 @@ #define XD_INDIRECT_VAL(code) ((-1 - (code)) & 255) #define XD_INDIRECT_DELTA(code) ((-1 - (code)) >> 8) -#define XD_DYNARR_DESC(base_type, sub_desc) \ - { XD_BLOCK_PTR, offsetof (base_type, base), \ - XD_INDIRECT(1, 0), {sub_desc} }, \ - { XD_INT, offsetof (base_type, len) }, \ - { XD_INT_RESET, offsetof (base_type, largest), XD_INDIRECT(1, 0) }, \ - { XD_INT_RESET, offsetof (base_type, max), XD_INDIRECT(1, 0) } - -#ifdef NEW_GC -#define XD_LISP_DYNARR_DESC(base_type, sub_desc) \ - { XD_LISP_OBJECT_BLOCK_PTR, offsetof (base_type, base), \ - XD_INDIRECT(1, 0), {sub_desc} }, \ - { XD_INT, offsetof (base_type, len) }, \ - { XD_INT_RESET, offsetof (base_type, largest), XD_INDIRECT(1, 0) }, \ - { XD_INT_RESET, offsetof (base_type, max), XD_INDIRECT(1, 0) } -#endif /* NEW_GC */ - /* DEFINE_LRECORD_IMPLEMENTATION is for objects with constant size. DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION is for objects whose size varies. */
--- a/src/mule-ccl.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/mule-ccl.c Wed Feb 03 20:51:18 2010 -0600 @@ -2366,7 +2366,7 @@ XVECTOR_DATA (status)[8] = make_int (ccl.ic); UNGCPRO; - val = make_string (Dynarr_atp (outbuf, 0), produced); + val = make_string (Dynarr_begin (outbuf), produced); Dynarr_free (outbuf); QUIT; if (ccl.status == CCL_STAT_SUSPEND_BY_DST)
--- a/src/mule-coding.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/mule-coding.c Wed Feb 03 20:51:18 2010 -0600 @@ -1889,7 +1889,7 @@ { Ibyte comstr[MAX_ICHAR_LEN]; Bytecount len; - Ichar emch = lookup_composite_char (Dynarr_atp (dst, 0), + Ichar emch = lookup_composite_char (Dynarr_begin (dst), Dynarr_length (dst)); dst = real_dst; len = set_itext_ichar (comstr, emch);
--- a/src/rangetab.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/rangetab.c Wed Feb 03 20:51:18 2010 -0600 @@ -355,7 +355,7 @@ rtnew->entries = Dynarr_new (range_table_entry); rtnew->type = rt->type; - Dynarr_add_many (rtnew->entries, Dynarr_atp (rt->entries, 0), + Dynarr_add_many (rtnew->entries, Dynarr_begin (rt->entries), Dynarr_length (rt->entries)); return wrap_range_table (rtnew); } @@ -374,7 +374,7 @@ CHECK_INT_COERCE_CHAR (pos); return get_range_table (XINT (pos), Dynarr_length (rt->entries), - Dynarr_atp (rt->entries, 0), default_); + Dynarr_begin (rt->entries), default_); } static void @@ -810,7 +810,7 @@ un = (struct unified_range_table *) new_dest; un->nentries = Dynarr_length (rted); un->type = XRANGE_TABLE (rangetab)->type; - memcpy (&un->first, Dynarr_atp (rted, 0), + memcpy (&un->first, Dynarr_begin (rted), sizeof (struct range_table_entry) * Dynarr_length (rted)); }
--- a/src/redisplay-msw.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/redisplay-msw.c Wed Feb 03 20:51:18 2010 -0600 @@ -469,7 +469,7 @@ #if 0 /* #### FIXME? */ /* We can't work out the width before we've set the font in the DC */ if (width < 0) - width = mswindows_text_width (w, cachel, Dynarr_atp (buf, 0), + width = mswindows_text_width (w, cachel, Dynarr_begin (buf), Dynarr_length (buf)); #else assert (width >= 0); @@ -518,7 +518,7 @@ cachel = WINDOW_FACE_CACHEL (w, findex); } - nruns = separate_textual_runs (&runs, Dynarr_atp (buf, 0), + nruns = separate_textual_runs (&runs, Dynarr_begin (buf), Dynarr_length (buf)); for (i = 0; i < nruns; i++)
--- a/src/redisplay-output.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/redisplay-output.c Wed Feb 03 20:51:18 2010 -0600 @@ -83,7 +83,7 @@ redisplay performance so avoiding all excess overhead is a good thing. Is all of this true? */ memcpy (cra->base, dra->base, sizeof (struct rune) * max_move); - Dynarr_set_size (cra, max_move); + Dynarr_set_length (cra, max_move); } else Dynarr_reset (cra); @@ -718,7 +718,7 @@ block, if present, must always be the first display block. */ assert (Dynarr_length (ddba) != 0); - db = Dynarr_atp (ddba, 0); + db = Dynarr_begin (ddba); assert (db->type == TEXT); get_cursor_size_and_location (w, db, ddl->cursor_elt, &cursor_start, @@ -1029,7 +1029,7 @@ w->last_point_y[CURRENT_DISP] = y; Fset_marker (w->last_point[CURRENT_DISP], Qzero, w->buffer); - rb = Dynarr_atp (db->runes, 0); + rb = Dynarr_begin (db->runes); rb->cursor_type = CURSOR_ON; dl->cursor_elt = 0; @@ -2196,7 +2196,7 @@ if (ddla_len) { - if (ddla_len == 1 && Dynarr_atp (ddla, 0)->modeline) + if (ddla_len == 1 && Dynarr_begin (ddla)->modeline) { ypos1 = WINDOW_TEXT_TOP (w); #ifdef HAVE_SCROLLBARS @@ -2398,9 +2398,9 @@ cdl = ddl = 0; if (cdla_len) - cdl = Dynarr_atp (cdla, 0); + cdl = Dynarr_begin (cdla); if (ddla_len) - ddl = Dynarr_atp (ddla, 0); + ddl = Dynarr_begin (ddla); if (!cdl || !ddl) need_to_clear_bottom = 1; @@ -2464,7 +2464,7 @@ /* If the number of display lines has shrunk, adjust. */ if (cdla_len > ddla_len) { - Dynarr_length (cdla) = ddla_len; + Dynarr_set_length (cdla, ddla_len); } /* Output a vertical divider between windows, if necessary. */
--- a/src/redisplay-tty.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/redisplay-tty.c Wed Feb 03 20:51:18 2010 -0600 @@ -575,12 +575,12 @@ else Dynarr_reset (tty_output_ichar_dynarr_dynarr); - convert_ichar_string_into_ibyte_dynarr (Dynarr_atp (buf, 0), + convert_ichar_string_into_ibyte_dynarr (Dynarr_begin (buf), Dynarr_length (buf), tty_output_ichar_dynarr_dynarr); tty_output_ibyte_string (w, dl, - Dynarr_atp (tty_output_ichar_dynarr_dynarr, 0), + Dynarr_begin (tty_output_ichar_dynarr_dynarr), Dynarr_length (tty_output_ichar_dynarr_dynarr), xpos, findex, cursor); } @@ -641,7 +641,7 @@ { substitute_in_dynamic_color_string (Vtty_dynamic_color_fg, Fsymbol_name (sym)); - escseq = Dynarr_atp (sidcs_dynarr, 0); + escseq = Dynarr_begin (sidcs_dynarr); escseqlen = Dynarr_length (sidcs_dynarr); } #endif @@ -671,7 +671,7 @@ { substitute_in_dynamic_color_string (Vtty_dynamic_color_bg, Fsymbol_name (sym)); - escseq = Dynarr_atp (sidcs_dynarr, 0); + escseq = Dynarr_begin (sidcs_dynarr); escseqlen = Dynarr_length (sidcs_dynarr); } #endif
--- a/src/redisplay-xlike-inc.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/redisplay-xlike-inc.c Wed Feb 03 20:51:18 2010 -0600 @@ -1022,7 +1022,7 @@ #endif /* USE_XFT */ if (width < 0) - width = XLIKE_text_width (w, cachel, Dynarr_atp (buf, 0), + width = XLIKE_text_width (w, cachel, Dynarr_begin (buf), Dynarr_length (buf)); /* Regularize the variables passed in. */ @@ -1086,7 +1086,7 @@ height); } - nruns = separate_textual_runs (text_storage, runs, Dynarr_atp (buf, 0), + nruns = separate_textual_runs (text_storage, runs, Dynarr_begin (buf), Dynarr_length (buf), cachel); for (i = 0; i < nruns; i++)
--- a/src/redisplay.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/redisplay.c Wed Feb 03 20:51:18 2010 -0600 @@ -661,7 +661,7 @@ nonreloc = XSTRING_DATA (reloc); convert_ibyte_string_into_ichar_dynarr (nonreloc, len, rtw_ichar_dynarr); return redisplay_window_text_width_ichar_string - (w, findex, Dynarr_atp (rtw_ichar_dynarr, 0), + (w, findex, Dynarr_begin (rtw_ichar_dynarr), Dynarr_length (rtw_ichar_dynarr)); } @@ -697,7 +697,7 @@ argument. */ text_width, (XWINDOW (window), &cachel, - Dynarr_atp (rtw_ichar_dynarr, 0), + Dynarr_begin (rtw_ichar_dynarr), Dynarr_length (rtw_ichar_dynarr))); } @@ -2312,9 +2312,9 @@ works because we always recalculate the extent-fragments for propagated data, we never actually propagate the fragments that still need to be displayed. */ - if (*prop && Dynarr_atp (*prop, 0)->type == PROP_GLYPH) - { - last_glyph = Dynarr_atp (*prop, 0)->data.p_glyph.glyph; + if (*prop && Dynarr_begin (*prop)->type == PROP_GLYPH) + { + last_glyph = Dynarr_begin (*prop)->data.p_glyph.glyph; Dynarr_free (*prop); *prop = 0; } @@ -4082,7 +4082,7 @@ true of max_pixsize. */ #define SET_CURRENT_MODE_CHARS_PIXSIZE \ if (Dynarr_length (data->db->runes)) \ - cur_pixsize = data->pixpos - Dynarr_atp (data->db->runes, 0)->xpos; \ + cur_pixsize = data->pixpos - Dynarr_begin (data->db->runes)->xpos; \ else \ cur_pixsize = 0; @@ -4208,7 +4208,7 @@ decode_mode_spec (w, ch, type); - str = Dynarr_atp (mode_spec_ibyte_string, 0); + str = Dynarr_begin (mode_spec_ibyte_string); size = bytecount_to_charcount /* Skip the null character added by `decode_mode_spec' */ (str, Dynarr_length (mode_spec_ibyte_string)) - 1; @@ -4489,11 +4489,11 @@ { display_line_dynarr *dla = window_display_lines (w, DESIRED_DISP); - if (!Dynarr_length (dla) || !Dynarr_atp (dla, 0)->modeline) + if (!Dynarr_length (dla) || !Dynarr_begin (dla)->modeline) return; else { - generate_modeline (w, Dynarr_atp (dla, 0), DESIRED_DISP); + generate_modeline (w, Dynarr_begin (dla), DESIRED_DISP); redisplay_update_line (w, 0, 0, 0); } } @@ -4545,7 +4545,7 @@ /* If we're adding a new place marker go ahead and generate the modeline so that it is available for use by window_modeline_height. */ - generate_modeline (w, Dynarr_atp (dla, 0), type); + generate_modeline (w, Dynarr_begin (dla), type); } return need_modeline; @@ -4564,9 +4564,9 @@ if (Dynarr_length (dla)) { - if (Dynarr_atp (dla, 0)->modeline) - return (Dynarr_atp (dla, 0)->ascent + - Dynarr_atp (dla, 0)->descent); + if (Dynarr_begin (dla)->modeline) + return (Dynarr_begin (dla)->ascent + + Dynarr_begin (dla)->descent); } } return 0; @@ -4781,9 +4781,9 @@ { Lisp_Object last_glyph = Qnil; /* Deal with clipped glyphs that we have already displayed. */ - if (*prop && Dynarr_atp (*prop, 0)->type == PROP_GLYPH) - { - last_glyph = Dynarr_atp (*prop, 0)->data.p_glyph.glyph; + if (*prop && Dynarr_begin (*prop)->type == PROP_GLYPH) + { + last_glyph = Dynarr_begin (*prop)->data.p_glyph.glyph; Dynarr_free (*prop); *prop = 0; } @@ -5649,7 +5649,7 @@ { /* We know that this is the right thing to use because we put it there when we first started working in this function. */ - generate_modeline (w, Dynarr_atp (dla, 0), type); + generate_modeline (w, Dynarr_begin (dla), type); } if (depth >= 0) @@ -5663,12 +5663,12 @@ return 0; \ else \ { \ - if (Dynarr_atp (cdla, 0)->modeline && Dynarr_atp (ddla, 0)->modeline) \ + if (Dynarr_begin (cdla)->modeline && Dynarr_begin (ddla)->modeline) \ { \ dla_start = 1; \ } \ - else if (!Dynarr_atp (cdla, 0)->modeline \ - && !Dynarr_atp (ddla, 0)->modeline) \ + else if (!Dynarr_begin (cdla)->modeline \ + && !Dynarr_begin (ddla)->modeline) \ { \ dla_start = 0; \ } \ @@ -6102,7 +6102,7 @@ display_line_dynarr *dla = window_display_lines (w, type); int first_line; - if (Dynarr_length (dla) && Dynarr_atp (dla, 0)->modeline) + if (Dynarr_length (dla) && Dynarr_begin (dla)->modeline) first_line = 1; else first_line = 0; @@ -7597,7 +7597,7 @@ { if (gba) { - glyph_block *gb = Dynarr_atp (gba, 0); + glyph_block *gb = Dynarr_begin (gba); glyph_block *gb_last = Dynarr_past_lastp (gba); for (; gb < gb_last; gb++) @@ -7732,7 +7732,7 @@ if (!Dynarr_length (cache)) return -1; else - return Dynarr_atp (cache, 0)->start; + return Dynarr_begin (cache)->start; } /* Return the very last buffer position contained in the given @@ -8227,7 +8227,7 @@ on that assert. So we have no option but to continue the search if we found point at the top of the line_start_cache again. */ - cur_pos = Dynarr_atp (w->line_start_cache,0)->start; + cur_pos = Dynarr_begin (w->line_start_cache)->start; } prev_pos = cur_pos; } @@ -8404,7 +8404,7 @@ if (!Dynarr_length (cache)) { - Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0), + Dynarr_add_many (cache, Dynarr_begin (internal_cache), Dynarr_length (internal_cache)); w->line_cache_validation_override--; return; @@ -8434,13 +8434,13 @@ if (!(ic_elt >= 0)) { Dynarr_reset (cache); - Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0), + Dynarr_add_many (cache, Dynarr_begin (internal_cache), Dynarr_length (internal_cache)); w->line_cache_validation_override--; return; } - Dynarr_insert_many_at_start (cache, Dynarr_atp (internal_cache, 0), + Dynarr_insert_many_at_start (cache, Dynarr_begin (internal_cache), ic_elt + 1); } @@ -8459,7 +8459,7 @@ if (!(ic_elt < Dynarr_length (internal_cache))) { Dynarr_reset (cache); - Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0), + Dynarr_add_many (cache, Dynarr_begin (internal_cache), Dynarr_length (internal_cache)); w->line_cache_validation_override--; return; @@ -8491,7 +8491,7 @@ to layout a single line. This is not possible since we force at least a single line to be layout for CMOTION_DISP */ assert (Dynarr_length (internal_cache)); - assert (startp == Dynarr_atp (internal_cache, 0)->start); + assert (startp == Dynarr_begin (internal_cache)->start); ic_elt = Dynarr_length (internal_cache) - 1; if (low_bound != -1) @@ -8526,7 +8526,7 @@ if (ic_elt >= 0) /* we still have lines to add.. */ { - Dynarr_insert_many (cache, Dynarr_atp (internal_cache, 0), + Dynarr_insert_many (cache, Dynarr_begin (internal_cache), ic_elt + 1, marker); marker += (ic_elt + 1); } @@ -8561,7 +8561,7 @@ /* See comment above about regenerate_window failing. */ assert (Dynarr_length (internal_cache)); - Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0), + Dynarr_add_many (cache, Dynarr_begin (internal_cache), Dynarr_length (internal_cache)); high_bound = Dynarr_lastp (cache)->end; startp = high_bound + 1; @@ -8606,7 +8606,7 @@ modeline = 0; if (num_disp_lines) { - if (Dynarr_atp (dla, 0)->modeline) + if (Dynarr_begin (dla)->modeline) { num_disp_lines--; modeline = 1; @@ -9063,9 +9063,9 @@ if (x_check <= left_bound) { if (dl->modeline) - *modeline_closest = Dynarr_atp (db->runes, 0)->charpos; + *modeline_closest = Dynarr_begin (db->runes)->charpos; else - *closest = Dynarr_atp (db->runes, 0)->charpos; + *closest = Dynarr_begin (db->runes)->charpos; } else {
--- a/src/sysdep.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/sysdep.c Wed Feb 03 20:51:18 2010 -0600 @@ -2773,7 +2773,7 @@ Dynarr_add_many (internal_DIRENTRY, internal_name, internal_len); Dynarr_add (internal_DIRENTRY, '\0'); /* NUL-terminate */ - return (DIRENTRY *) Dynarr_atp (internal_DIRENTRY, 0); + return (DIRENTRY *) Dynarr_begin (internal_DIRENTRY); } } #endif /* MULE */
--- a/src/text.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/text.c Wed Feb 03 20:51:18 2010 -0600 @@ -4238,7 +4238,7 @@ /* double zero-extend because we may be dealing with Unicode data */ Dynarr_add (conversion_out_dynarr, '\0'); Dynarr_add (conversion_out_dynarr, '\0'); - sink->data.ptr = Dynarr_atp (conversion_out_dynarr, 0); + sink->data.ptr = Dynarr_begin (conversion_out_dynarr); } PROFILE_RECORD_EXITING_SECTION (QSin_internal_external_conversion); @@ -4470,7 +4470,7 @@ cases. So we add a second zero, just like for external data (in that case, because we may be converting to Unicode). */ Dynarr_add (conversion_in_dynarr, '\0'); - sink->data.ptr = Dynarr_atp (conversion_in_dynarr, 0); + sink->data.ptr = Dynarr_begin (conversion_in_dynarr); } PROFILE_RECORD_EXITING_SECTION (QSin_internal_external_conversion);
--- a/src/toolbar-common.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/toolbar-common.c Wed Feb 03 20:51:18 2010 -0600 @@ -296,7 +296,7 @@ buf = Dynarr_new (Ichar); convert_ibyte_string_into_ichar_dynarr (XSTRING_DATA (string), XSTRING_LENGTH (string), buf); - find_charsets_in_ichar_string (charsets, Dynarr_atp (buf, 0), + find_charsets_in_ichar_string (charsets, Dynarr_begin (buf), Dynarr_length (buf)); ensure_face_cachel_complete (cachel, window, charsets); face_cachel_charset_font_metric_info (cachel, charsets, &fm);
--- a/src/window.c Mon Feb 01 14:11:36 2010 -0600 +++ b/src/window.c Wed Feb 03 20:51:18 2010 -0600 @@ -1125,15 +1125,15 @@ since there is a redisplay condition that these structures be identical outside of redisplay. */ dla = window_display_lines (w, DESIRED_DISP); - if (dla && Dynarr_length (dla) && Dynarr_atp (dla, 0)->modeline) - modeline_height = (Dynarr_atp (dla, 0)->ascent + - Dynarr_atp (dla, 0)->descent); + if (dla && Dynarr_length (dla) && Dynarr_begin (dla)->modeline) + modeline_height = (Dynarr_begin (dla)->ascent + + Dynarr_begin (dla)->descent); else { dla = window_display_lines (w, CURRENT_DISP); - if (dla && Dynarr_length (dla) && Dynarr_atp (dla, 0)->modeline) - modeline_height = (Dynarr_atp (dla, 0)->ascent + - Dynarr_atp (dla, 0)->descent); + if (dla && Dynarr_length (dla) && Dynarr_begin (dla)->modeline) + modeline_height = (Dynarr_begin (dla)->ascent + + Dynarr_begin (dla)->descent); else /* This should be an abort except I'm not yet 100% confident that it won't ever get hit (though I @@ -1923,7 +1923,7 @@ struct display_line *dl; /* No lines - no clipped lines */ - if (num_lines == 0 || (num_lines == 1 && Dynarr_atp (dla, 0)->modeline)) + if (num_lines == 0 || (num_lines == 1 && Dynarr_begin (dla)->modeline)) return Qnil; dl = Dynarr_atp (dla, num_lines - 1); @@ -4209,7 +4209,7 @@ indicates that end-of-buffer is being displayed. */ if (end_pos == -1) { - struct display_line *dl = Dynarr_atp (dla, 0); + struct display_line *dl = Dynarr_begin (dla); int ypos1 = dl->ypos + dl->descent; int ypos2 = WINDOW_TEXT_BOTTOM (w); Lisp_Object window; @@ -4244,7 +4244,7 @@ } else { - if (num_lines > 1 && Dynarr_atp (dla, 0)->modeline) + if (num_lines > 1 && Dynarr_begin (dla)->modeline) num_lines--; if (scroll_on_clipped_lines @@ -4617,7 +4617,7 @@ default_face_height_and_width (window, &fheight, &fwidth); if (Dynarr_length (dla) >= 1) - modeline = Dynarr_atp (dla, 0)->modeline; + modeline = Dynarr_begin (dla)->modeline; dl = Dynarr_atp (dla, modeline); @@ -5305,7 +5305,7 @@ CHECK_INT (pos); point = XINT (pos); - if (Dynarr_length (dla) && Dynarr_atp (dla, 0)->modeline) + if (Dynarr_length (dla) && Dynarr_begin (dla)->modeline) first_line = 1; else first_line = 0;