From 9046e924421869bf167b52cd394e868796091f62 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 13 Feb 2018 22:07:12 -0800 Subject: [PATCH] [subset] Rename constructor to hb_subset_input_create_or_fail() To signify that unlike rest of library, returns nullptr on failure. --- src/hb-subset-input.cc | 6 ++---- src/hb-subset.h | 2 +- test/api/test-subset-glyf.c | 3 ++- test/api/test-subset.c | 7 +++++-- util/hb-subset.cc | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/hb-subset-input.cc b/src/hb-subset-input.cc index 75c016843..d41cff601 100644 --- a/src/hb-subset-input.cc +++ b/src/hb-subset-input.cc @@ -29,19 +29,17 @@ #include "hb-set-private.hh" /** - * hb_subset_input_create: + * hb_subset_input_create_or_fail: * * Return value: New subset input. * * Since: 1.8.0 **/ hb_subset_input_t * -hb_subset_input_create (void) +hb_subset_input_create_or_fail (void) { hb_subset_input_t *input = hb_object_create(); - /* Unlike libharfbuzz, in this lib we return nullptr - * in case of allocation failure. */ if (unlikely (!input)) return nullptr; diff --git a/src/hb-subset.h b/src/hb-subset.h index 81e11fe65..de7759b22 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -54,7 +54,7 @@ hb_subset_profile_destroy (hb_subset_profile_t *profile); typedef struct hb_subset_input_t hb_subset_input_t; HB_EXTERN hb_subset_input_t * -hb_subset_input_create (void); +hb_subset_input_create_or_fail (void); HB_EXTERN hb_subset_input_t * hb_subset_input_reference (hb_subset_input_t *subset_input); diff --git a/test/api/test-subset-glyf.c b/test/api/test-subset-glyf.c index 014f24338..62af9399f 100644 --- a/test/api/test-subset-glyf.c +++ b/test/api/test-subset-glyf.c @@ -95,9 +95,10 @@ test_subset_glyf (void) hb_blob_t *glyf_expected_blob; hb_blob_t *glyf_actual_blob; hb_subset_profile_t *profile = hb_subset_profile_create(); - hb_subset_input_t *input = hb_subset_input_create (); + hb_subset_input_t *input = hb_subset_input_create_or_fail (); hb_set_t *codepoints = hb_set_reference (hb_subset_input_unicode_set (input)); + g_assert (input); g_assert (face_abc); g_assert (face_ac); diff --git a/test/api/test-subset.c b/test/api/test-subset.c index 44eba1581..68c001347 100644 --- a/test/api/test-subset.c +++ b/test/api/test-subset.c @@ -43,12 +43,15 @@ test_subset (void) hb_face_t *face = hb_face_create(font_blob, 0); hb_subset_profile_t *profile = hb_subset_profile_create(); - hb_subset_input_t *input = hb_subset_input_create (); + hb_subset_input_t *input = hb_subset_input_create_or_fail (); hb_face_t *out_face = hb_subset(face, profile, input); + hb_blob_t *output; + + g_assert (input); g_assert(out_face); g_assert(out_face != hb_face_get_empty ()); - hb_blob_t *output = hb_face_reference_blob (out_face); + output = hb_face_reference_blob (out_face); unsigned int output_length; const char *output_data = hb_blob_get_data(output, &output_length); diff --git a/util/hb-subset.cc b/util/hb-subset.cc index 16abd14d5..ea657affe 100644 --- a/util/hb-subset.cc +++ b/util/hb-subset.cc @@ -43,7 +43,7 @@ struct subset_consumer_t const font_options_t *font_opts) { font = hb_font_reference (font_opts->get_font ()); - input = hb_subset_input_create (); + input = hb_subset_input_create_or_fail (); } void consume_line (const char *text,