提交 e6c09cdf 编写于 作者: B Behdad Esfahbod

Remove the pre_allocate argument from hb_buffer_create()

For two reasons:

1. User can always call hb_buffer_pre_allocate() themselves, and

2. Now we do a pre_alloc in add_utfX anyway, so the total number of
reallocs is limited to a small number (~3) anyway.  This just makes the
API cleaner.
上级 187bdeaa
......@@ -486,7 +486,7 @@ void hb_buffer_t::deallocate_var_all (void)
/* Public API */
hb_buffer_t *
hb_buffer_create (unsigned int pre_alloc_size)
hb_buffer_create ()
{
hb_buffer_t *buffer;
......@@ -495,11 +495,6 @@ hb_buffer_create (unsigned int pre_alloc_size)
buffer->reset ();
if (pre_alloc_size && !buffer->ensure (pre_alloc_size)) {
hb_buffer_destroy (buffer);
return &_hb_buffer_nil;
}
return buffer;
}
......
......@@ -60,7 +60,7 @@ typedef struct _hb_glyph_position_t {
hb_buffer_t *
hb_buffer_create (unsigned int pre_alloc_size);
hb_buffer_create (void);
hb_buffer_t *
hb_buffer_get_empty (void);
......
......@@ -97,7 +97,7 @@ main (int argc, char **argv)
hb_ft_font_set_funcs (font);
#endif
hb_buffer_t *buffer = hb_buffer_create (0);
hb_buffer_t *buffer = hb_buffer_create ();
hb_buffer_add_utf8 (buffer, "\xe0\xa4\x95\xe0\xa5\x8d\xe0\xa4\xb0\xe0\xa5\x8d\xe0\xa4\x95", -1, 0, -1);
......
......@@ -62,7 +62,7 @@ fixture_init (fixture_t *fixture, gconstpointer user_data)
hb_buffer_t *b;
unsigned int i;
b = fixture->buffer = hb_buffer_create (0);
b = fixture->buffer = hb_buffer_create ();
switch (GPOINTER_TO_INT (user_data))
{
......@@ -344,7 +344,7 @@ test_buffer_utf8_conversion (void)
hb_glyph_info_t *glyphs;
unsigned int bytes, chars, i, j, len;
b = hb_buffer_create (0);
b = hb_buffer_create ();
for (i = 0; i < G_N_ELEMENTS (utf8_conversion_tests); i++)
{
......@@ -627,7 +627,7 @@ test_buffer_utf8_validity (void)
hb_buffer_t *b;
unsigned int i;
b = hb_buffer_create (0);
b = hb_buffer_create ();
for (i = 0; i < G_N_ELEMENTS (utf8_validity_tests); i++)
{
......@@ -684,7 +684,7 @@ test_buffer_utf16_conversion (void)
hb_buffer_t *b;
unsigned int i;
b = hb_buffer_create (0);
b = hb_buffer_create ();
for (i = 0; i < G_N_ELEMENTS (utf16_conversion_tests); i++)
{
......@@ -726,7 +726,6 @@ test_buffer_empty (void)
g_assert (hb_buffer_get_empty ());
g_assert (hb_buffer_get_empty () == b);
g_assert (hb_buffer_get_empty () == hb_buffer_create (-1));
g_assert (!hb_buffer_allocation_successful (b));
......
......@@ -44,12 +44,12 @@ create_blob_inert (void)
static void *
create_buffer (void)
{
return hb_buffer_create (0);
return hb_buffer_create ();
}
static void *
create_buffer_inert (void)
{
return hb_buffer_create (-1);
return NULL;
}
static void *
......
......@@ -1038,7 +1038,7 @@ test_shape_complex (ft_fixture_t *f, gconstpointer user_data)
if (data->comments[0])
g_test_message ("Test comments: %s", data->comments);
buffer = hb_buffer_create (0);
buffer = hb_buffer_create ();
for (len = 0; data->characters[len]; len++) ;
hb_buffer_add_utf32 (buffer, data->characters, len, 0, len);
......
......@@ -106,7 +106,7 @@ test_shape (void)
hb_font_set_funcs (font, ffuncs, NULL, NULL);
hb_font_funcs_destroy (ffuncs);
buffer = hb_buffer_create (0);
buffer = hb_buffer_create ();
hb_buffer_set_direction (buffer, HB_DIRECTION_LTR);
hb_buffer_add_utf8 (buffer, TesT, 4, 0, 4);
......
......@@ -59,7 +59,7 @@ _hb_cr_text_glyphs (cairo_t *cr,
unsigned int num_glyphs, i;
hb_position_t x, y;
hb_buffer = hb_buffer_create (0);
hb_buffer = hb_buffer_create ();
if (shape_opts->direction)
hb_buffer_set_direction (hb_buffer, hb_direction_from_string (shape_opts->direction));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册