From 9417c1c0d2b005eadf0c087ca695121a6200d0f7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 20 Apr 2011 17:21:23 -0400 Subject: [PATCH] [API] Make hb_face_reference_table() return empty blob instead of NULL The idea here is that: - Like pretty much all other API in harfbuzz, user does not have to check for NULL. - In any caller code, the case of missing table should be handled exactly the same way that a too-short table is handled. Turning a non-existent talbe into a table of size 0 makes the user code safer. --- src/hb-font.cc | 2 ++ src/hb-open-type-private.hh | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hb-font.cc b/src/hb-font.cc index 2475089..96ff4f5 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -417,6 +417,8 @@ hb_face_reference_table (hb_face_t *face, return &_hb_blob_nil; blob = face->get_table (tag, face->user_data); + if (unlikely (!blob)) + blob = hb_blob_create_empty(); return blob; } diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 8f3001b..241c5a0 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -286,9 +286,6 @@ struct Sanitizer /* TODO is_sane() stuff */ - if (!blob) - return hb_blob_create_empty (); - retry: (void) (HB_DEBUG_SANITIZE && fprintf (stderr, "Sanitizer %p start %s\n", blob, HB_FUNC)); -- 2.7.4