diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index 11639efce..68ef59435 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -260,6 +260,12 @@ hb_buffer_pre_allocate (hb_buffer_t *buffer, unsigned int size) return _hb_buffer_ensure (buffer, size); } +hb_bool_t +hb_buffer_allocation_successful (hb_buffer_t *buffer) +{ + return !buffer->in_error; +} + void hb_buffer_add_glyph (hb_buffer_t *buffer, hb_codepoint_t codepoint, diff --git a/src/hb-buffer.h b/src/hb-buffer.h index 0c3ef3a31..c22e31d32 100644 --- a/src/hb-buffer.h +++ b/src/hb-buffer.h @@ -106,10 +106,16 @@ hb_buffer_get_language (hb_buffer_t *buffer); void hb_buffer_reset (hb_buffer_t *buffer); +/* Returns FALSE if allocation failed */ hb_bool_t hb_buffer_pre_allocate (hb_buffer_t *buffer, unsigned int size); + +/* Returns FALSE if allocation has failed before */ +hb_bool_t +hb_buffer_allocation_successful (hb_buffer_t *buffer); + void hb_buffer_reverse (hb_buffer_t *buffer); diff --git a/test/test-buffer.c b/test/test-buffer.c index c2b199b1f..952251551 100644 --- a/test/test-buffer.c +++ b/test/test-buffer.c @@ -185,7 +185,7 @@ main (int argc, char **argv) /* XXX test invalid UTF-8 / UTF-16 text input (also overlong sequences) */ /* XXX test reverse() and reverse_clusters() */ - /* XXX test ensure() and memory management */ + /* XXX test pre_allocate(), allocation_successful(), and memory management */ /* XXX test buffer reset */ /* XXX test buffer set length */