| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 1998-2004 David Turner and Werner Lemberg | 2 * Copyright © 1998-2004 David Turner and Werner Lemberg |
| 3 * Copyright © 2004,2007,2009,2010 Red Hat, Inc. | 3 * Copyright © 2004,2007,2009,2010 Red Hat, Inc. |
| 4 * Copyright © 2011,2012 Google, Inc. | 4 * Copyright © 2011,2012 Google, Inc. |
| 5 * | 5 * |
| 6 * This is part of HarfBuzz, a text shaping library. | 6 * This is part of HarfBuzz, a text shaping library. |
| 7 * | 7 * |
| 8 * Permission is hereby granted, without written agreement and without | 8 * Permission is hereby granted, without written agreement and without |
| 9 * license or royalty fees, to use, copy, modify, and distribute this | 9 * license or royalty fees, to use, copy, modify, and distribute this |
| 10 * software and its documentation for any purpose, provided that the | 10 * software and its documentation for any purpose, provided that the |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 | 85 |
| 86 | 86 |
| 87 /* Internal API */ | 87 /* Internal API */ |
| 88 | 88 |
| 89 bool | 89 bool |
| 90 hb_buffer_t::enlarge (unsigned int size) | 90 hb_buffer_t::enlarge (unsigned int size) |
| 91 { | 91 { |
| 92 if (unlikely (in_error)) | 92 if (unlikely (in_error)) |
| 93 return false; | 93 return false; |
| 94 if (unlikely (size > max_len)) |
| 95 { |
| 96 in_error = true; |
| 97 return false; |
| 98 } |
| 94 | 99 |
| 95 unsigned int new_allocated = allocated; | 100 unsigned int new_allocated = allocated; |
| 96 hb_glyph_position_t *new_pos = NULL; | 101 hb_glyph_position_t *new_pos = NULL; |
| 97 hb_glyph_info_t *new_info = NULL; | 102 hb_glyph_info_t *new_info = NULL; |
| 98 bool separate_out = out_info != info; | 103 bool separate_out = out_info != info; |
| 99 | 104 |
| 100 if (unlikely (_hb_unsigned_int_mul_overflows (size, sizeof (info[0])))) | 105 if (unlikely (_hb_unsigned_int_mul_overflows (size, sizeof (info[0])))) |
| 101 goto done; | 106 goto done; |
| 102 | 107 |
| 103 while (size >= new_allocated) | 108 while (size >= new_allocated) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 } | 196 } |
| 192 | 197 |
| 193 void | 198 void |
| 194 hb_buffer_t::clear (void) | 199 hb_buffer_t::clear (void) |
| 195 { | 200 { |
| 196 if (unlikely (hb_object_is_inert (this))) | 201 if (unlikely (hb_object_is_inert (this))) |
| 197 return; | 202 return; |
| 198 | 203 |
| 199 hb_segment_properties_t default_props = HB_SEGMENT_PROPERTIES_DEFAULT; | 204 hb_segment_properties_t default_props = HB_SEGMENT_PROPERTIES_DEFAULT; |
| 200 props = default_props; | 205 props = default_props; |
| 206 scratch_flags = HB_BUFFER_SCRATCH_FLAG_DEFAULT; |
| 201 | 207 |
| 202 content_type = HB_BUFFER_CONTENT_TYPE_INVALID; | 208 content_type = HB_BUFFER_CONTENT_TYPE_INVALID; |
| 203 in_error = false; | 209 in_error = false; |
| 204 have_output = false; | 210 have_output = false; |
| 205 have_positions = false; | 211 have_positions = false; |
| 206 | 212 |
| 207 idx = 0; | 213 idx = 0; |
| 208 len = 0; | 214 len = 0; |
| 209 out_len = 0; | 215 out_len = 0; |
| 210 out_info = info; | 216 out_info = info; |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 * Since: 0.9.2 | 713 * Since: 0.9.2 |
| 708 **/ | 714 **/ |
| 709 hb_buffer_t * | 715 hb_buffer_t * |
| 710 hb_buffer_create (void) | 716 hb_buffer_create (void) |
| 711 { | 717 { |
| 712 hb_buffer_t *buffer; | 718 hb_buffer_t *buffer; |
| 713 | 719 |
| 714 if (!(buffer = hb_object_create<hb_buffer_t> ())) | 720 if (!(buffer = hb_object_create<hb_buffer_t> ())) |
| 715 return hb_buffer_get_empty (); | 721 return hb_buffer_get_empty (); |
| 716 | 722 |
| 723 buffer->max_len = HB_BUFFER_MAX_LEN_DEFAULT; |
| 724 |
| 717 buffer->reset (); | 725 buffer->reset (); |
| 718 | 726 |
| 719 return buffer; | 727 return buffer; |
| 720 } | 728 } |
| 721 | 729 |
| 722 /** | 730 /** |
| 723 * hb_buffer_get_empty: | 731 * hb_buffer_get_empty: |
| 724 * | 732 * |
| 725 * | 733 * |
| 726 * | 734 * |
| 727 * Return value: (transfer full): | 735 * Return value: (transfer full): |
| 728 * | 736 * |
| 729 * Since: 0.9.2 | 737 * Since: 0.9.2 |
| 730 **/ | 738 **/ |
| 731 hb_buffer_t * | 739 hb_buffer_t * |
| 732 hb_buffer_get_empty (void) | 740 hb_buffer_get_empty (void) |
| 733 { | 741 { |
| 734 static const hb_buffer_t _hb_buffer_nil = { | 742 static const hb_buffer_t _hb_buffer_nil = { |
| 735 HB_OBJECT_HEADER_STATIC, | 743 HB_OBJECT_HEADER_STATIC, |
| 736 | 744 |
| 737 const_cast<hb_unicode_funcs_t *> (&_hb_unicode_funcs_nil), | 745 const_cast<hb_unicode_funcs_t *> (&_hb_unicode_funcs_nil), |
| 738 HB_BUFFER_FLAG_DEFAULT, | 746 HB_BUFFER_FLAG_DEFAULT, |
| 739 HB_BUFFER_CLUSTER_LEVEL_DEFAULT, | 747 HB_BUFFER_CLUSTER_LEVEL_DEFAULT, |
| 740 HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT, | 748 HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT, |
| 749 HB_BUFFER_SCRATCH_FLAG_DEFAULT, |
| 750 HB_BUFFER_MAX_LEN_DEFAULT, |
| 741 | 751 |
| 742 HB_BUFFER_CONTENT_TYPE_INVALID, | 752 HB_BUFFER_CONTENT_TYPE_INVALID, |
| 743 HB_SEGMENT_PROPERTIES_DEFAULT, | 753 HB_SEGMENT_PROPERTIES_DEFAULT, |
| 744 true, /* in_error */ | 754 true, /* in_error */ |
| 745 true, /* have_output */ | 755 true, /* have_output */ |
| 746 true /* have_positions */ | 756 true /* have_positions */ |
| 747 | 757 |
| 748 /* Zero is good enough for everything else. */ | 758 /* Zero is good enough for everything else. */ |
| 749 }; | 759 }; |
| 750 | 760 |
| (...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1692 continue; | 1702 continue; |
| 1693 /* Move item i to occupy place for item j, shift what's in between. */ | 1703 /* Move item i to occupy place for item j, shift what's in between. */ |
| 1694 merge_clusters (j, i + 1); | 1704 merge_clusters (j, i + 1); |
| 1695 { | 1705 { |
| 1696 hb_glyph_info_t t = info[i]; | 1706 hb_glyph_info_t t = info[i]; |
| 1697 memmove (&info[j + 1], &info[j], (i - j) * sizeof (hb_glyph_info_t)); | 1707 memmove (&info[j + 1], &info[j], (i - j) * sizeof (hb_glyph_info_t)); |
| 1698 info[j] = t; | 1708 info[j] = t; |
| 1699 } | 1709 } |
| 1700 } | 1710 } |
| 1701 } | 1711 } |
| OLD | NEW |