From dbdbfe3d7b36613d893832dcb1884c756c20bfda Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 15 Oct 2017 12:11:08 +0200 Subject: [PATCH] Use nullptr instead of NULL --- src/hb-blob.cc | 12 +-- src/hb-buffer-serialize.cc | 16 +-- src/hb-buffer.cc | 10 +- src/hb-common.cc | 18 ++-- src/hb-coretext.cc | 66 ++++++------- src/hb-directwrite.cc | 28 +++--- src/hb-face.cc | 10 +- src/hb-font.cc | 32 +++--- src/hb-ft.cc | 56 +++++------ src/hb-glib.cc | 2 +- src/hb-gobject-structs.cc | 2 +- src/hb-graphite2.cc | 26 ++--- src/hb-icu.cc | 4 +- src/hb-mutex-private.hh | 2 +- src/hb-object-private.hh | 2 +- src/hb-open-type-private.hh | 32 +++--- src/hb-ot-cbdt-table.hh | 4 +- src/hb-ot-cmap-table.hh | 2 +- src/hb-ot-font.cc | 42 ++++---- src/hb-ot-layout-common-private.hh | 14 +-- src/hb-ot-layout-gsub-table.hh | 2 +- src/hb-ot-layout-gsubgpos-private.hh | 54 +++++----- src/hb-ot-layout-jstf-table.hh | 4 +- src/hb-ot-layout.cc | 30 +++--- src/hb-ot-map-private.hh | 6 +- src/hb-ot-map.cc | 4 +- src/hb-ot-math-table.hh | 8 +- src/hb-ot-shape-complex-arabic-fallback.hh | 8 +- src/hb-ot-shape-complex-arabic.cc | 32 +++--- src/hb-ot-shape-complex-default.cc | 22 ++--- src/hb-ot-shape-complex-hangul.cc | 12 +-- src/hb-ot-shape-complex-hebrew.cc | 18 ++-- src/hb-ot-shape-complex-indic.cc | 12 +-- src/hb-ot-shape-complex-myanmar.cc | 40 ++++---- src/hb-ot-shape-complex-private.hh | 26 ++--- src/hb-ot-shape-complex-thai.cc | 22 ++--- src/hb-ot-shape-complex-tibetan.cc | 20 ++-- src/hb-ot-shape-complex-use.cc | 16 +-- src/hb-ot-shape-private.hh | 2 +- src/hb-ot-shape.cc | 8 +- src/hb-ot-tag.cc | 2 +- src/hb-ot-var.cc | 2 +- src/hb-private.hh | 37 +++---- src/hb-set-private.hh | 2 +- src/hb-shape-plan.cc | 24 ++--- src/hb-shape.cc | 8 +- src/hb-shaper-private.hh | 6 +- src/hb-shaper.cc | 6 +- src/hb-ucdn.cc | 2 +- src/hb-unicode.cc | 4 +- src/hb-uniscribe.cc | 50 +++++----- src/main.cc | 4 +- src/test-buffer-serialize.cc | 8 +- src/test-size-params.cc | 6 +- src/test-would-substitute.cc | 8 +- src/test.cc | 12 +-- util/ansi-print.cc | 2 +- util/hb-fc.cc | 6 +- util/hb-ot-shape-closure.cc | 10 +- util/hb-shape.cc | 14 +-- util/helper-cairo.cc | 12 +-- util/main-font-text.hh | 4 +- util/options.cc | 110 ++++++++++----------- util/options.hh | 56 +++++------ util/shape-consumer.hh | 10 +- 65 files changed, 563 insertions(+), 568 deletions(-) diff --git a/src/hb-blob.cc b/src/hb-blob.cc index 41e99da0d..e390d7520 100644 --- a/src/hb-blob.cc +++ b/src/hb-blob.cc @@ -72,8 +72,8 @@ _hb_blob_destroy_user_data (hb_blob_t *blob) { if (blob->destroy) { blob->destroy (blob->user_data); - blob->user_data = NULL; - blob->destroy = NULL; + blob->user_data = nullptr; + blob->destroy = nullptr; } } @@ -194,12 +194,12 @@ hb_blob_get_empty (void) true, /* immutable */ - NULL, /* data */ + nullptr, /* data */ 0, /* length */ HB_MEMORY_MODE_READONLY, /* mode */ - NULL, /* user_data */ - NULL /* destroy */ + nullptr, /* user_data */ + nullptr /* destroy */ }; return const_cast (&_hb_blob_nil); @@ -379,7 +379,7 @@ hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length) if (length) *length = 0; - return NULL; + return nullptr; } if (length) diff --git a/src/hb-buffer-serialize.cc b/src/hb-buffer-serialize.cc index 517d746ef..ea62e9ffd 100644 --- a/src/hb-buffer-serialize.cc +++ b/src/hb-buffer-serialize.cc @@ -30,7 +30,7 @@ static const char *serialize_formats[] = { "text", "json", - NULL + nullptr }; /** @@ -90,7 +90,7 @@ hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format) case HB_BUFFER_SERIALIZE_FORMAT_TEXT: return serialize_formats[0]; case HB_BUFFER_SERIALIZE_FORMAT_JSON: return serialize_formats[1]; default: - case HB_BUFFER_SERIALIZE_FORMAT_INVALID: return NULL; + case HB_BUFFER_SERIALIZE_FORMAT_INVALID: return nullptr; } } @@ -104,9 +104,9 @@ _hb_buffer_serialize_glyphs_json (hb_buffer_t *buffer, hb_font_t *font, hb_buffer_serialize_flags_t flags) { - hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, NULL); + hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, nullptr); hb_glyph_position_t *pos = (flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS) ? - NULL : hb_buffer_get_glyph_positions (buffer, NULL); + nullptr : hb_buffer_get_glyph_positions (buffer, nullptr); *buf_consumed = 0; for (unsigned int i = start; i < end; i++) @@ -194,9 +194,9 @@ _hb_buffer_serialize_glyphs_text (hb_buffer_t *buffer, hb_font_t *font, hb_buffer_serialize_flags_t flags) { - hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, NULL); + hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, nullptr); hb_glyph_position_t *pos = (flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS) ? - NULL : hb_buffer_get_glyph_positions (buffer, NULL); + nullptr : hb_buffer_get_glyph_positions (buffer, nullptr); *buf_consumed = 0; for (unsigned int i = start; i < end; i++) @@ -422,8 +422,8 @@ hb_bool_t hb_buffer_deserialize_glyphs (hb_buffer_t *buffer, const char *buf, int buf_len, /* -1 means nul-terminated */ - const char **end_ptr, /* May be NULL */ - hb_font_t *font, /* May be NULL */ + const char **end_ptr, /* May be nullptr */ + hb_font_t *font, /* May be nullptr */ hb_buffer_serialize_format_t format) { const char *end; diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index 25b798b58..73b3e4bd5 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -120,8 +120,8 @@ hb_buffer_t::enlarge (unsigned int size) } unsigned int new_allocated = allocated; - hb_glyph_position_t *new_pos = NULL; - hb_glyph_info_t *new_info = NULL; + hb_glyph_position_t *new_pos = nullptr; + hb_glyph_info_t *new_info = nullptr; bool separate_out = out_info != info; if (unlikely (_hb_unsigned_int_mul_overflows (size, sizeof (info[0])))) @@ -1993,9 +1993,9 @@ hb_buffer_set_message_func (hb_buffer_t *buffer, buffer->message_data = user_data; buffer->message_destroy = destroy; } else { - buffer->message_func = NULL; - buffer->message_data = NULL; - buffer->message_destroy = NULL; + buffer->message_func = nullptr; + buffer->message_data = nullptr; + buffer->message_destroy = nullptr; } } diff --git a/src/hb-common.cc b/src/hb-common.cc index 8e8e55653..2f9b3b853 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -274,13 +274,13 @@ retry: /* Not found; allocate one. */ hb_language_item_t *lang = (hb_language_item_t *) calloc (1, sizeof (hb_language_item_t)); if (unlikely (!lang)) - return NULL; + return nullptr; lang->next = first_lang; *lang = key; if (unlikely (!lang->lang)) { free (lang); - return NULL; + return nullptr; } if (!hb_atomic_ptr_cmpexch (&langs, first_lang, lang)) { @@ -318,7 +318,7 @@ hb_language_from_string (const char *str, int len) if (!str || !len || !*str) return HB_LANGUAGE_INVALID; - hb_language_item_t *item = NULL; + hb_language_item_t *item = nullptr; if (len >= 0) { /* NUL-terminate it. */ @@ -349,7 +349,7 @@ hb_language_from_string (const char *str, int len) const char * hb_language_to_string (hb_language_t language) { - /* This is actually NULL-safe! */ + /* This is actually nullptr-safe! */ return language->s; } @@ -369,7 +369,7 @@ hb_language_get_default (void) hb_language_t language = (hb_language_t) hb_atomic_ptr_get (&default_language); if (unlikely (language == HB_LANGUAGE_INVALID)) { - language = hb_language_from_string (setlocale (LC_CTYPE, NULL), -1); + language = hb_language_from_string (setlocale (LC_CTYPE, nullptr), -1); (void) hb_atomic_ptr_cmpexch (&default_language, HB_LANGUAGE_INVALID, language); } @@ -562,9 +562,9 @@ hb_user_data_array_t::set (hb_user_data_key_t *key, void * hb_user_data_array_t::get (hb_user_data_key_t *key) { - hb_user_data_item_t item = {NULL, NULL, NULL}; + hb_user_data_item_t item = {nullptr, nullptr, nullptr}; - return items.find (key, &item, lock) ? item.data : NULL; + return items.find (key, &item, lock) ? item.data : nullptr; } @@ -722,9 +722,9 @@ retry: if (unlikely (!C)) { - C = newlocale (LC_ALL_MASK, "C", NULL); + C = newlocale (LC_ALL_MASK, "C", nullptr); - if (!hb_atomic_ptr_cmpexch (&C_locale, NULL, C)) + if (!hb_atomic_ptr_cmpexch (&C_locale, nullptr, C)) { freelocale (C_locale); goto retry; diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc index 56979391d..ca5483334 100644 --- a/src/hb-coretext.cc +++ b/src/hb-coretext.cc @@ -65,12 +65,12 @@ reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data) CGFontRef cg_font = reinterpret_cast (user_data); CFDataRef cf_data = CGFontCopyTableForTag (cg_font, tag); if (unlikely (!cf_data)) - return NULL; + return nullptr; const char *data = reinterpret_cast (CFDataGetBytePtr (cf_data)); const size_t length = CFDataGetLength (cf_data); if (!data || !length) - return NULL; + return nullptr; return hb_blob_create (data, length, HB_MEMORY_MODE_READONLY, reinterpret_cast (const_cast<__CFData *> (cf_data)), @@ -125,7 +125,7 @@ static void release_data (void *info, const void *data, size_t size) { assert (hb_blob_get_length ((hb_blob_t *) info) == size && - hb_blob_get_data ((hb_blob_t *) info, NULL) == data); + hb_blob_get_data ((hb_blob_t *) info, nullptr) == data); hb_blob_destroy ((hb_blob_t *) info); } @@ -133,7 +133,7 @@ release_data (void *info, const void *data, size_t size) static CGFontRef create_cg_font (hb_face_t *face) { - CGFontRef cg_font = NULL; + CGFontRef cg_font = nullptr; if (face->destroy == _hb_cg_font_release) { cg_font = CGFontRetain ((CGFontRef) face->user_data); @@ -161,7 +161,7 @@ create_cg_font (hb_face_t *face) static CTFontRef create_ct_font (CGFontRef cg_font, CGFloat font_size) { - CTFontRef ct_font = NULL; + CTFontRef ct_font = nullptr; /* CoreText does not enable trak table usage / tracking when creating a CTFont * using CTFontCreateWithGraphicsFont. The only way of enabling tracking seems @@ -174,23 +174,23 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size) if (CFStringHasSuffix (cg_postscript_name, CFSTR ("-Bold"))) font_type = kCTFontUIFontEmphasizedSystem; - ct_font = CTFontCreateUIFontForLanguage (font_type, font_size, NULL); + ct_font = CTFontCreateUIFontForLanguage (font_type, font_size, nullptr); CFStringRef ct_result_name = CTFontCopyPostScriptName(ct_font); if (CFStringCompare (ct_result_name, cg_postscript_name, 0) != kCFCompareEqualTo) { CFRelease(ct_font); - ct_font = NULL; + ct_font = nullptr; } CFRelease (ct_result_name); } CFRelease (cg_postscript_name); if (!ct_font) - ct_font = CTFontCreateWithGraphicsFont (cg_font, font_size, NULL, NULL); + ct_font = CTFontCreateWithGraphicsFont (cg_font, font_size, nullptr, nullptr); if (unlikely (!ct_font)) { DEBUG_MSG (CORETEXT, cg_font, "Font CTFontCreateWithGraphicsFont() failed"); - return NULL; + return nullptr; } /* crbug.com/576941 and crbug.com/625902 and the investigation in the latter @@ -200,7 +200,7 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size) * reconfiguring the cascade list causes CoreText crashes. For details, see * crbug.com/549610 */ // 0x00070000 stands for "kCTVersionNumber10_10", see CoreText.h - if (&CTGetCoreTextVersion != NULL && CTGetCoreTextVersion() < 0x00070000) { + if (&CTGetCoreTextVersion != nullptr && CTGetCoreTextVersion() < 0x00070000) { CFStringRef fontName = CTFontCopyPostScriptName (ct_font); bool isEmojiFont = CFStringCompare (fontName, CFSTR("AppleColorEmoji"), 0) == kCFCompareEqualTo; CFRelease (fontName); @@ -214,7 +214,7 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size) * font fallback which we don't need anyway. */ { CTFontDescriptorRef last_resort_font_desc = get_last_resort_font_desc (); - CTFontRef new_ct_font = CTFontCreateCopyWithAttributes (ct_font, 0.0, NULL, last_resort_font_desc); + CTFontRef new_ct_font = CTFontCreateCopyWithAttributes (ct_font, 0.0, nullptr, last_resort_font_desc); CFRelease (last_resort_font_desc); if (new_ct_font) { @@ -257,7 +257,7 @@ _hb_coretext_shaper_face_data_create (hb_face_t *face) if (unlikely (!cg_font)) { DEBUG_MSG (CORETEXT, face, "CGFont creation failed.."); - return NULL; + return nullptr; } return (hb_coretext_shaper_face_data_t *) cg_font; @@ -275,7 +275,7 @@ _hb_coretext_shaper_face_data_destroy (hb_coretext_shaper_face_data_t *data) CGFontRef hb_coretext_face_get_cg_font (hb_face_t *face) { - if (unlikely (!hb_coretext_shaper_face_data_ensure (face))) return NULL; + if (unlikely (!hb_coretext_shaper_face_data_ensure (face))) return nullptr; return (CGFontRef) HB_SHAPER_DATA_GET (face); } @@ -288,7 +288,7 @@ hb_coretext_shaper_font_data_t * _hb_coretext_shaper_font_data_create (hb_font_t *font) { hb_face_t *face = font->face; - if (unlikely (!hb_coretext_shaper_face_data_ensure (face))) return NULL; + if (unlikely (!hb_coretext_shaper_face_data_ensure (face))) return nullptr; CGFontRef cg_font = (CGFontRef) HB_SHAPER_DATA_GET (face); CTFontRef ct_font = create_ct_font (cg_font, coretext_font_size (font->ptem)); @@ -296,7 +296,7 @@ _hb_coretext_shaper_font_data_create (hb_font_t *font) if (unlikely (!ct_font)) { DEBUG_MSG (CORETEXT, font, "CGFont creation failed.."); - return NULL; + return nullptr; } return (hb_coretext_shaper_font_data_t *) ct_font; @@ -333,7 +333,7 @@ _hb_coretext_shaper_shape_plan_data_destroy (hb_coretext_shaper_shape_plan_data_ CTFontRef hb_coretext_font_get_ct_font (hb_font_t *font) { - if (unlikely (!hb_coretext_shaper_font_data_ensure (font))) return NULL; + if (unlikely (!hb_coretext_shaper_font_data_ensure (font))) return nullptr; return (CTFontRef)HB_SHAPER_DATA_GET (font); } @@ -704,12 +704,12 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan, CTFontDescriptorRef font_desc = CTFontDescriptorCreateWithAttributes (attributes); CFRelease (attributes); - range->font = CTFontCreateCopyWithAttributes (ct_font, 0.0, NULL, font_desc); + range->font = CTFontCreateCopyWithAttributes (ct_font, 0.0, nullptr, font_desc); CFRelease (font_desc); } else { - range->font = NULL; + range->font = nullptr; } range->index_first = last_index; @@ -779,14 +779,14 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan, #define FAIL(...) \ HB_STMT_START { \ - DEBUG_MSG (CORETEXT, NULL, __VA_ARGS__); \ + DEBUG_MSG (CORETEXT, nullptr, __VA_ARGS__); \ ret = false; \ goto fail; \ } HB_STMT_END; bool ret = true; - CFStringRef string_ref = NULL; - CTLineRef line = NULL; + CFStringRef string_ref = nullptr; + CTLineRef line = nullptr; if (0) { @@ -798,8 +798,8 @@ resize_and_retry: assert (line); CFRelease (string_ref); CFRelease (line); - string_ref = NULL; - line = NULL; + string_ref = nullptr; + line = nullptr; /* Get previous start-of-scratch-area, that we use later for readjusting * our existing scratch arrays. */ @@ -820,7 +820,7 @@ resize_and_retry: scratch_size -= old_scratch_used; } { - string_ref = CFStringCreateWithCharactersNoCopy (NULL, + string_ref = CFStringCreateWithCharactersNoCopy (nullptr, pchars, chars_len, kCFAllocatorNull); if (unlikely (!string_ref)) @@ -937,7 +937,7 @@ resize_and_retry: CFArrayRef glyph_runs = CTLineGetGlyphRuns (line); unsigned int num_runs = CFArrayGetCount (glyph_runs); - DEBUG_MSG (CORETEXT, NULL, "Num runs: %d", num_runs); + DEBUG_MSG (CORETEXT, nullptr, "Num runs: %d", num_runs); buffer->len = 0; uint32_t status_and = ~0, status_or = 0; @@ -963,7 +963,7 @@ resize_and_retry: status_or |= run_status; status_and &= run_status; DEBUG_MSG (CORETEXT, run, "CTRunStatus: %x", run_status); - double run_advance = CTRunGetTypographicBounds (run, range_all, NULL, NULL, NULL); + double run_advance = CTRunGetTypographicBounds (run, range_all, nullptr, nullptr, nullptr); if (HB_DIRECTION_IS_VERTICAL (buffer->props.direction)) run_advance = -run_advance; DEBUG_MSG (CORETEXT, run, "Run advance: %g", run_advance); @@ -1089,7 +1089,7 @@ resize_and_retry: /* Testing used to indicate that CTRunGetGlyphsPtr, etc (almost?) always * succeed, and so copying data to our own buffer will be rare. Reports - * have it that this changed in OS X 10.10 Yosemite, and NULL is returned + * have it that this changed in OS X 10.10 Yosemite, and nullptr is returned * frequently. At any rate, we can test that codepath by setting USE_PTR * to false. */ @@ -1105,13 +1105,13 @@ resize_and_retry: { /* Setup glyphs */ SCRATCH_SAVE(); - const CGGlyph* glyphs = USE_PTR ? CTRunGetGlyphsPtr (run) : NULL; + const CGGlyph* glyphs = USE_PTR ? CTRunGetGlyphsPtr (run) : nullptr; if (!glyphs) { ALLOCATE_ARRAY (CGGlyph, glyph_buf, num_glyphs, goto resize_and_retry); CTRunGetGlyphs (run, range_all, glyph_buf); glyphs = glyph_buf; } - const CFIndex* string_indices = USE_PTR ? CTRunGetStringIndicesPtr (run) : NULL; + const CFIndex* string_indices = USE_PTR ? CTRunGetStringIndicesPtr (run) : nullptr; if (!string_indices) { ALLOCATE_ARRAY (CFIndex, index_buf, num_glyphs, goto resize_and_retry); CTRunGetStringIndices (run, range_all, index_buf); @@ -1133,7 +1133,7 @@ resize_and_retry: * advance (in the advance direction only), and for last glyph we set * whatever is needed to make the whole run's advance add up. */ SCRATCH_SAVE(); - const CGPoint* positions = USE_PTR ? CTRunGetPositionsPtr (run) : NULL; + const CGPoint* positions = USE_PTR ? CTRunGetPositionsPtr (run) : nullptr; if (!positions) { ALLOCATE_ARRAY (CGPoint, position_buf, num_glyphs, goto resize_and_retry); CTRunGetPositions (run, range_all, position_buf); @@ -1300,12 +1300,12 @@ _hb_coretext_aat_shaper_face_data_create (hb_face_t *face) if (hb_blob_get_length (blob)) { hb_blob_destroy (blob); - return hb_coretext_shaper_face_data_ensure (face) ? (hb_coretext_aat_shaper_face_data_t *) HB_SHAPER_DATA_SUCCEEDED : NULL; + return hb_coretext_shaper_face_data_ensure (face) ? (hb_coretext_aat_shaper_face_data_t *) HB_SHAPER_DATA_SUCCEEDED : nullptr; } hb_blob_destroy (blob); } - return NULL; + return nullptr; } void @@ -1323,7 +1323,7 @@ struct hb_coretext_aat_shaper_font_data_t {}; hb_coretext_aat_shaper_font_data_t * _hb_coretext_aat_shaper_font_data_create (hb_font_t *font) { - return hb_coretext_shaper_font_data_ensure (font) ? (hb_coretext_aat_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED : NULL; + return hb_coretext_shaper_font_data_ensure (font) ? (hb_coretext_aat_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED : nullptr; } void diff --git a/src/hb-directwrite.cc b/src/hb-directwrite.cc index 14df8221b..a6693ef3a 100644 --- a/src/hb-directwrite.cc +++ b/src/hb-directwrite.cc @@ -140,7 +140,7 @@ _hb_directwrite_shaper_face_data_create(hb_face_t *face) hb_directwrite_shaper_face_data_t *data = (hb_directwrite_shaper_face_data_t *) malloc (sizeof (hb_directwrite_shaper_face_data_t)); if (unlikely (!data)) - return NULL; + return nullptr; // TODO: factory and fontFileLoader should be cached separately IDWriteFactory* dwriteFactory; @@ -153,7 +153,7 @@ _hb_directwrite_shaper_face_data_create(hb_face_t *face) HRESULT hr; hb_blob_t *blob = hb_face_reference_blob (face); IDWriteFontFileStream *fontFileStream = new DWriteFontFileStream ( - (uint8_t*) hb_blob_get_data (blob, NULL), hb_blob_get_length (blob)); + (uint8_t*) hb_blob_get_data (blob, nullptr), hb_blob_get_length (blob)); IDWriteFontFileLoader *fontFileLoader = new DWriteFontFileLoader (fontFileStream); dwriteFactory->RegisterFontFileLoader (fontFileLoader); @@ -165,7 +165,7 @@ _hb_directwrite_shaper_face_data_create(hb_face_t *face) #define FAIL(...) \ HB_STMT_START { \ - DEBUG_MSG (DIRECTWRITE, NULL, __VA_ARGS__); \ + DEBUG_MSG (DIRECTWRITE, nullptr, __VA_ARGS__); \ return false; \ } HB_STMT_END; @@ -233,12 +233,12 @@ struct hb_directwrite_shaper_font_data_t { hb_directwrite_shaper_font_data_t * _hb_directwrite_shaper_font_data_create (hb_font_t *font) { - if (unlikely (!hb_directwrite_shaper_face_data_ensure (font->face))) return NULL; + if (unlikely (!hb_directwrite_shaper_face_data_ensure (font->face))) return nullptr; hb_directwrite_shaper_font_data_t *data = (hb_directwrite_shaper_font_data_t *) malloc (sizeof (hb_directwrite_shaper_font_data_t)); if (unlikely (!data)) - return NULL; + return nullptr; return data; } @@ -313,7 +313,7 @@ public: , mTextLength(textLength) , mLocaleName(localeName) , mReadingDirection(readingDirection) - , mCurrentRun(NULL) { }; + , mCurrentRun(nullptr) { }; ~TextAnalysis() { // delete runs, except mRunHead which is part of the TextAnalysis object @@ -337,7 +337,7 @@ public: mRunHead.mTextLength = mTextLength; mRunHead.mBidiLevel = (mReadingDirection == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT); - mRunHead.nextRun = NULL; + mRunHead.nextRun = nullptr; mCurrentRun = &mRunHead; // Call each of the analyzers in sequence, recording their results. @@ -356,7 +356,7 @@ public: { if (textPosition >= mTextLength) { // No text at this position, valid query though. - *textString = NULL; + *textString = nullptr; *textLength = 0; } else { @@ -373,7 +373,7 @@ public: if (textPosition == 0 || textPosition > mTextLength) { // Either there is no text before here (== 0), or this // is an invalid position. The query is considered valid thouh. - *textString = NULL; + *textString = nullptr; *textLength = 0; } else { @@ -399,7 +399,7 @@ public: OUT IDWriteNumberSubstitution** numberSubstitution) { // We do not support number substitution. - *numberSubstitution = NULL; + *numberSubstitution = nullptr; *textLength = mTextLength - textPosition; return S_OK; @@ -617,14 +617,14 @@ _hb_directwrite_shape_full(hb_shape_plan_t *shape_plan, */ uint32_t textLength = buffer->len; - TextAnalysis analysis(textString, textLength, NULL, readingDirection); + TextAnalysis analysis(textString, textLength, nullptr, readingDirection); TextAnalysis::Run *runHead; HRESULT hr; hr = analysis.GenerateResults(analyzer, &runHead); #define FAIL(...) \ HB_STMT_START { \ - DEBUG_MSG (DIRECTWRITE, NULL, __VA_ARGS__); \ + DEBUG_MSG (DIRECTWRITE, nullptr, __VA_ARGS__); \ return false; \ } HB_STMT_END; @@ -639,7 +639,7 @@ _hb_directwrite_shape_full(hb_shape_plan_t *shape_plan, bool isRightToLeft = HB_DIRECTION_IS_BACKWARD (buffer->props.direction); const wchar_t localeName[20] = {0}; - if (buffer->props.language != NULL) + if (buffer->props.language != nullptr) { mbstowcs ((wchar_t*) localeName, hb_language_to_string (buffer->props.language), 20); @@ -672,7 +672,7 @@ retry_getglyphs: malloc (maxGlyphCount * sizeof (DWRITE_SHAPING_GLYPH_PROPERTIES)); hr = analyzer->GetGlyphs (textString, textLength, fontFace, false, - isRightToLeft, &runHead->mScript, localeName, NULL, &dwFeatures, + isRightToLeft, &runHead->mScript, localeName, nullptr, &dwFeatures, featureRangeLengths, 1, maxGlyphCount, clusterMap, textProperties, glyphIndices, glyphProperties, &glyphCount); diff --git a/src/hb-face.cc b/src/hb-face.cc index e96c8acd3..26fddbe52 100644 --- a/src/hb-face.cc +++ b/src/hb-face.cc @@ -43,9 +43,9 @@ const hb_face_t _hb_face_nil = { true, /* immutable */ - NULL, /* reference_table_func */ - NULL, /* user_data */ - NULL, /* destroy */ + nullptr, /* reference_table_func */ + nullptr, /* user_data */ + nullptr, /* destroy */ 0, /* index */ 1000, /* upem */ @@ -57,7 +57,7 @@ const hb_face_t _hb_face_nil = { #undef HB_SHAPER_IMPLEMENT }, - NULL, /* shape_plans */ + nullptr, /* shape_plans */ }; @@ -109,7 +109,7 @@ _hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index) closure = (hb_face_for_data_closure_t *) calloc (1, sizeof (hb_face_for_data_closure_t)); if (unlikely (!closure)) - return NULL; + return nullptr; closure->blob = blob; closure->index = index; diff --git a/src/hb-font.cc b/src/hb-font.cc index 5673e66e3..c03917e14 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -347,12 +347,12 @@ static const hb_font_funcs_t _hb_font_funcs_nil = { true, /* immutable */ { -#define HB_FONT_FUNC_IMPLEMENT(name) NULL, +#define HB_FONT_FUNC_IMPLEMENT(name) nullptr, HB_FONT_FUNCS_IMPLEMENT_CALLBACKS #undef HB_FONT_FUNC_IMPLEMENT }, { -#define HB_FONT_FUNC_IMPLEMENT(name) NULL, +#define HB_FONT_FUNC_IMPLEMENT(name) nullptr, HB_FONT_FUNCS_IMPLEMENT_CALLBACKS #undef HB_FONT_FUNC_IMPLEMENT }, @@ -370,12 +370,12 @@ static const hb_font_funcs_t _hb_font_funcs_parent = { true, /* immutable */ { -#define HB_FONT_FUNC_IMPLEMENT(name) NULL, +#define HB_FONT_FUNC_IMPLEMENT(name) nullptr, HB_FONT_FUNCS_IMPLEMENT_CALLBACKS #undef HB_FONT_FUNC_IMPLEMENT }, { -#define HB_FONT_FUNC_IMPLEMENT(name) NULL, +#define HB_FONT_FUNC_IMPLEMENT(name) nullptr, HB_FONT_FUNCS_IMPLEMENT_CALLBACKS #undef HB_FONT_FUNC_IMPLEMENT }, @@ -563,8 +563,8 @@ hb_font_funcs_set_##name##_func (hb_font_funcs_t *ffuncs, \ ffuncs->destroy.name = destroy; \ } else { \ ffuncs->get.f.name = hb_font_get_##name##_parent; \ - ffuncs->user_data.name = NULL; \ - ffuncs->destroy.name = NULL; \ + ffuncs->user_data.name = nullptr; \ + ffuncs->destroy.name = nullptr; \ } \ } @@ -1161,7 +1161,7 @@ hb_font_create_sub_font (hb_font_t *parent) font->num_coords = parent->num_coords; if (!font->num_coords) - font->coords = NULL; + font->coords = nullptr; else { unsigned int size = parent->num_coords * sizeof (parent->coords[0]); @@ -1192,7 +1192,7 @@ hb_font_get_empty (void) true, /* immutable */ - NULL, /* parent */ + nullptr, /* parent */ const_cast (&_hb_face_nil), 1000, /* x_scale */ @@ -1203,11 +1203,11 @@ hb_font_get_empty (void) 0, /* ptem */ 0, /* num_coords */ - NULL, /* coords */ + nullptr, /* coords */ const_cast (&_hb_font_funcs_nil), /* klass */ - NULL, /* user_data */ - NULL, /* destroy */ + nullptr, /* user_data */ + nullptr, /* destroy */ { #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, @@ -1639,13 +1639,13 @@ hb_font_set_variations (hb_font_t *font, if (!variations_length) { - hb_font_set_var_coords_normalized (font, NULL, 0); + hb_font_set_var_coords_normalized (font, nullptr, 0); return; } unsigned int coords_length = hb_ot_var_get_axis_count (font->face); - int *normalized = coords_length ? (int *) calloc (coords_length, sizeof (int)) : NULL; + int *normalized = coords_length ? (int *) calloc (coords_length, sizeof (int)) : nullptr; if (unlikely (coords_length && !normalized)) return; @@ -1668,7 +1668,7 @@ hb_font_set_var_coords_design (hb_font_t *font, if (font->immutable) return; - int *normalized = coords_length ? (int *) calloc (coords_length, sizeof (int)) : NULL; + int *normalized = coords_length ? (int *) calloc (coords_length, sizeof (int)) : nullptr; if (unlikely (coords_length && !normalized)) return; @@ -1689,7 +1689,7 @@ hb_font_set_var_coords_normalized (hb_font_t *font, if (font->immutable) return; - int *copy = coords_length ? (int *) calloc (coords_length, sizeof (coords[0])) : NULL; + int *copy = coords_length ? (int *) calloc (coords_length, sizeof (coords[0])) : nullptr; if (unlikely (coords_length && !copy)) return; @@ -1749,7 +1749,7 @@ trampoline_create (FuncType func, trampoline_t *trampoline = (trampoline_t *) calloc (1, sizeof (trampoline_t)); if (unlikely (!trampoline)) - return NULL; + return nullptr; trampoline->closure.user_data = user_data; trampoline->closure.destroy = destroy; diff --git a/src/hb-ft.cc b/src/hb-ft.cc index 83af9942e..6036f301a 100644 --- a/src/hb-ft.cc +++ b/src/hb-ft.cc @@ -83,7 +83,7 @@ _hb_ft_font_create (FT_Face ft_face, bool symbol, bool unref) hb_ft_font_t *ft_font = (hb_ft_font_t *) calloc (1, sizeof (hb_ft_font_t)); if (unlikely (!ft_font)) - return NULL; + return nullptr; ft_font->ft_face = ft_face; ft_font->symbol = symbol; @@ -158,7 +158,7 @@ FT_Face hb_ft_font_get_face (hb_font_t *font) { if (font->destroy != _hb_ft_font_destroy) - return NULL; + return nullptr; const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font->user_data; @@ -424,7 +424,7 @@ hb_ft_get_font_h_extents (hb_font_t *font HB_UNUSED, return true; } -static hb_font_funcs_t *static_ft_funcs = NULL; +static hb_font_funcs_t *static_ft_funcs = nullptr; #ifdef HB_USE_ATEXIT static @@ -444,24 +444,24 @@ retry: { funcs = hb_font_funcs_create (); - hb_font_funcs_set_font_h_extents_func (funcs, hb_ft_get_font_h_extents, NULL, NULL); - //hb_font_funcs_set_font_v_extents_func (funcs, hb_ft_get_font_v_extents, NULL, NULL); - hb_font_funcs_set_nominal_glyph_func (funcs, hb_ft_get_nominal_glyph, NULL, NULL); - hb_font_funcs_set_variation_glyph_func (funcs, hb_ft_get_variation_glyph, NULL, NULL); - hb_font_funcs_set_glyph_h_advance_func (funcs, hb_ft_get_glyph_h_advance, NULL, NULL); - hb_font_funcs_set_glyph_v_advance_func (funcs, hb_ft_get_glyph_v_advance, NULL, NULL); - //hb_font_funcs_set_glyph_h_origin_func (funcs, hb_ft_get_glyph_h_origin, NULL, NULL); - hb_font_funcs_set_glyph_v_origin_func (funcs, hb_ft_get_glyph_v_origin, NULL, NULL); - hb_font_funcs_set_glyph_h_kerning_func (funcs, hb_ft_get_glyph_h_kerning, NULL, NULL); - //hb_font_funcs_set_glyph_v_kerning_func (funcs, hb_ft_get_glyph_v_kerning, NULL, NULL); - hb_font_funcs_set_glyph_extents_func (funcs, hb_ft_get_glyph_extents, NULL, NULL); - hb_font_funcs_set_glyph_contour_point_func (funcs, hb_ft_get_glyph_contour_point, NULL, NULL); - hb_font_funcs_set_glyph_name_func (funcs, hb_ft_get_glyph_name, NULL, NULL); - hb_font_funcs_set_glyph_from_name_func (funcs, hb_ft_get_glyph_from_name, NULL, NULL); + hb_font_funcs_set_font_h_extents_func (funcs, hb_ft_get_font_h_extents, nullptr, nullptr); + //hb_font_funcs_set_font_v_extents_func (funcs, hb_ft_get_font_v_extents, nullptr, nullptr); + hb_font_funcs_set_nominal_glyph_func (funcs, hb_ft_get_nominal_glyph, nullptr, nullptr); + hb_font_funcs_set_variation_glyph_func (funcs, hb_ft_get_variation_glyph, nullptr, nullptr); + hb_font_funcs_set_glyph_h_advance_func (funcs, hb_ft_get_glyph_h_advance, nullptr, nullptr); + hb_font_funcs_set_glyph_v_advance_func (funcs, hb_ft_get_glyph_v_advance, nullptr, nullptr); + //hb_font_funcs_set_glyph_h_origin_func (funcs, hb_ft_get_glyph_h_origin, nullptr, nullptr); + hb_font_funcs_set_glyph_v_origin_func (funcs, hb_ft_get_glyph_v_origin, nullptr, nullptr); + hb_font_funcs_set_glyph_h_kerning_func (funcs, hb_ft_get_glyph_h_kerning, nullptr, nullptr); + //hb_font_funcs_set_glyph_v_kerning_func (funcs, hb_ft_get_glyph_v_kerning, nullptr, nullptr); + hb_font_funcs_set_glyph_extents_func (funcs, hb_ft_get_glyph_extents, nullptr, nullptr); + hb_font_funcs_set_glyph_contour_point_func (funcs, hb_ft_get_glyph_contour_point, nullptr, nullptr); + hb_font_funcs_set_glyph_name_func (funcs, hb_ft_get_glyph_name, nullptr, nullptr); + hb_font_funcs_set_glyph_from_name_func (funcs, hb_ft_get_glyph_from_name, nullptr, nullptr); hb_font_funcs_make_immutable (funcs); - if (!hb_atomic_ptr_cmpexch (&static_ft_funcs, NULL, funcs)) { + if (!hb_atomic_ptr_cmpexch (&static_ft_funcs, nullptr, funcs)) { hb_font_funcs_destroy (funcs); goto retry; } @@ -490,17 +490,17 @@ reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data) /* Note: FreeType like HarfBuzz uses the NONE tag for fetching the entire blob */ - error = FT_Load_Sfnt_Table (ft_face, tag, 0, NULL, &length); + error = FT_Load_Sfnt_Table (ft_face, tag, 0, nullptr, &length); if (error) - return NULL; + return nullptr; buffer = (FT_Byte *) malloc (length); if (!buffer) - return NULL; + return nullptr; error = FT_Load_Sfnt_Table (ft_face, tag, 0, buffer, &length); if (error) - return NULL; + return nullptr; return hb_blob_create ((const char *) buffer, length, HB_MEMORY_MODE_WRITABLE, @@ -581,7 +581,7 @@ hb_ft_face_create_cached (FT_Face ft_face) if (ft_face->generic.finalizer) ft_face->generic.finalizer (ft_face); - ft_face->generic.data = hb_ft_face_create (ft_face, NULL); + ft_face->generic.data = hb_ft_face_create (ft_face, nullptr); ft_face->generic.finalizer = (FT_Generic_Finalizer) hb_ft_face_finalize; } @@ -633,7 +633,7 @@ hb_ft_font_changed (hb_font_t *font) #endif #ifdef HAVE_FT_GET_VAR_BLEND_COORDINATES - FT_MM_Var *mm_var = NULL; + FT_MM_Var *mm_var = nullptr; if (!FT_Get_MM_Var (ft_face, &mm_var)) { FT_Fixed *ft_coords = (FT_Fixed *) calloc (mm_var->num_axis, sizeof (FT_Fixed)); @@ -694,9 +694,9 @@ retry: { /* Not found; allocate one. */ if (FT_Init_FreeType (&library)) - return NULL; + return nullptr; - if (!hb_atomic_ptr_cmpexch (&ft_library, NULL, library)) { + if (!hb_atomic_ptr_cmpexch (&ft_library, nullptr, library)) { FT_Done_FreeType (library); goto retry; } @@ -724,7 +724,7 @@ hb_ft_font_set_funcs (hb_font_t *font) if (unlikely (!blob_length)) DEBUG_MSG (FT, font, "Font face has empty blob"); - FT_Face ft_face = NULL; + FT_Face ft_face = nullptr; FT_Error err = FT_New_Memory_Face (get_ft_library (), (const FT_Byte *) blob_data, blob_length, @@ -751,7 +751,7 @@ hb_ft_font_set_funcs (hb_font_t *font) { FT_Matrix matrix = { font->x_scale < 0 ? -1 : +1, 0, 0, font->y_scale < 0 ? -1 : +1}; - FT_Set_Transform (ft_face, &matrix, NULL); + FT_Set_Transform (ft_face, &matrix, nullptr); } unsigned int num_coords; diff --git a/src/hb-glib.cc b/src/hb-glib.cc index 8b499558b..5b0a1eb32 100644 --- a/src/hb-glib.cc +++ b/src/hb-glib.cc @@ -370,7 +370,7 @@ hb_glib_get_unicode_funcs (void) static const hb_unicode_funcs_t _hb_glib_unicode_funcs = { HB_OBJECT_HEADER_STATIC, - NULL, /* parent */ + nullptr, /* parent */ true, /* immutable */ { #define HB_UNICODE_FUNC_IMPLEMENT(name) hb_glib_unicode_##name, diff --git a/src/hb-gobject-structs.cc b/src/hb-gobject-structs.cc index fef00245b..a96c35804 100644 --- a/src/hb-gobject-structs.cc +++ b/src/hb-gobject-structs.cc @@ -58,7 +58,7 @@ hb_gobject_##name##_get_type (void) \ static hb_##name##_t *_hb_##name##_reference (const hb_##name##_t *l) \ { \ hb_##name##_t *c = (hb_##name##_t *) calloc (1, sizeof (hb_##name##_t)); \ - if (unlikely (!c)) return NULL; \ + if (unlikely (!c)) return nullptr; \ *c = *l; \ return c; \ } \ diff --git a/src/hb-graphite2.cc b/src/hb-graphite2.cc index bc247c60c..6f0598dd0 100644 --- a/src/hb-graphite2.cc +++ b/src/hb-graphite2.cc @@ -59,7 +59,7 @@ static const void *hb_graphite2_get_table (const void *data, unsigned int tag, s hb_graphite2_shaper_face_data_t *face_data = (hb_graphite2_shaper_face_data_t *) data; hb_graphite2_tablelist_t *tlist = face_data->tlist; - hb_blob_t *blob = NULL; + hb_blob_t *blob = nullptr; for (hb_graphite2_tablelist_t *p = tlist; p; p = p->next) if (p->tag == tag) { @@ -74,7 +74,7 @@ static const void *hb_graphite2_get_table (const void *data, unsigned int tag, s hb_graphite2_tablelist_t *p = (hb_graphite2_tablelist_t *) calloc (1, sizeof (hb_graphite2_tablelist_t)); if (unlikely (!p)) { hb_blob_destroy (blob); - return NULL; + return nullptr; } p->blob = blob; p->tag = tag; @@ -100,20 +100,20 @@ _hb_graphite2_shaper_face_data_create (hb_face_t *face) if (!hb_blob_get_length (silf_blob)) { hb_blob_destroy (silf_blob); - return NULL; + return nullptr; } hb_blob_destroy (silf_blob); hb_graphite2_shaper_face_data_t *data = (hb_graphite2_shaper_face_data_t *) calloc (1, sizeof (hb_graphite2_shaper_face_data_t)); if (unlikely (!data)) - return NULL; + return nullptr; data->face = face; data->grface = gr_make_face (data, &hb_graphite2_get_table, gr_face_preloadAll); if (unlikely (!data->grface)) { free (data); - return NULL; + return nullptr; } return data; @@ -143,7 +143,7 @@ _hb_graphite2_shaper_face_data_destroy (hb_graphite2_shaper_face_data_t *data) gr_face * hb_graphite2_face_get_gr_face (hb_face_t *face) { - if (unlikely (!hb_graphite2_shaper_face_data_ensure (face))) return NULL; + if (unlikely (!hb_graphite2_shaper_face_data_ensure (face))) return nullptr; return HB_SHAPER_DATA_GET (face)->grface; } @@ -171,7 +171,7 @@ _hb_graphite2_shaper_font_data_destroy (hb_graphite2_shaper_font_data_t *data HB gr_font * hb_graphite2_font_get_gr_font (hb_font_t *font) { - return NULL; + return nullptr; } @@ -221,7 +221,7 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan, gr_face *grface = HB_SHAPER_DATA_GET (face)->grface; const char *lang = hb_language_to_string (hb_buffer_get_language (buffer)); - const char *lang_end = lang ? strchr (lang, '-') : NULL; + const char *lang_end = lang ? strchr (lang, '-') : nullptr; int lang_len = lang_end ? lang_end - lang : -1; gr_feature_val *feats = gr_face_featureval_for_lang (grface, lang ? hb_tag_from_string (lang, lang_len) : 0); @@ -232,7 +232,7 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan, gr_fref_set_feature_value (fref, features[i].value, feats); } - gr_segment *seg = NULL; + gr_segment *seg = nullptr; const gr_slot *is; unsigned int ci = 0, ic = 0; float curradvx = 0., curradvy = 0.; @@ -250,7 +250,7 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan, hb_tag_t script_tag[2]; hb_ot_tags_from_script (hb_buffer_get_script (buffer), &script_tag[0], &script_tag[1]); - seg = gr_make_seg (NULL, grface, + seg = gr_make_seg (nullptr, grface, script_tag[1] == HB_TAG_NONE ? script_tag[0] : script_tag[1], feats, gr_utf32, chars, buffer->len, @@ -368,7 +368,7 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan, /* Positioning. */ unsigned int currclus = (unsigned int) -1; const hb_glyph_info_t *info = buffer->info; - hb_glyph_position_t *pPos = hb_buffer_get_glyph_positions (buffer, NULL); + hb_glyph_position_t *pPos = hb_buffer_get_glyph_positions (buffer, nullptr); if (!HB_DIRECTION_IS_BACKWARD(buffer->props.direction)) { curradvx = 0; @@ -383,7 +383,7 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan, } else pPos->x_advance = 0.; - pPos->y_advance = gr_slot_advance_Y (is, grface, NULL) * yscale; + pPos->y_advance = gr_slot_advance_Y (is, grface, nullptr) * yscale; curradvy += pPos->y_advance; } } @@ -400,7 +400,7 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan, } else pPos->x_advance = 0.; - pPos->y_advance = gr_slot_advance_Y (is, grface, NULL) * yscale; + pPos->y_advance = gr_slot_advance_Y (is, grface, nullptr) * yscale; curradvy -= pPos->y_advance; pPos->x_offset = (gr_slot_origin_X (is) - info->var1.i32) * xscale - curradvx + pPos->x_advance; pPos->y_offset = gr_slot_origin_Y (is) * yscale - curradvy; diff --git a/src/hb-icu.cc b/src/hb-icu.cc index ee54721fd..ce179e337 100644 --- a/src/hb-icu.cc +++ b/src/hb-icu.cc @@ -351,7 +351,7 @@ hb_icu_get_unicode_funcs (void) static const hb_unicode_funcs_t _hb_icu_unicode_funcs = { HB_OBJECT_HEADER_STATIC, - NULL, /* parent */ + nullptr, /* parent */ true, /* immutable */ { #define HB_UNICODE_FUNC_IMPLEMENT(name) hb_icu_unicode_##name, @@ -364,7 +364,7 @@ hb_icu_get_unicode_funcs (void) if (!hb_atomic_ptr_get (&normalizer)) { UErrorCode icu_err = U_ZERO_ERROR; /* We ignore failure in getNFCInstace(). */ - (void) hb_atomic_ptr_cmpexch (&normalizer, NULL, unorm2_getNFCInstance (&icu_err)); + (void) hb_atomic_ptr_cmpexch (&normalizer, nullptr, unorm2_getNFCInstance (&icu_err)); } #endif return const_cast (&_hb_icu_unicode_funcs); diff --git a/src/hb-mutex-private.hh b/src/hb-mutex-private.hh index ed2703571..49ed10e08 100644 --- a/src/hb-mutex-private.hh +++ b/src/hb-mutex-private.hh @@ -68,7 +68,7 @@ typedef CRITICAL_SECTION hb_mutex_impl_t; #include typedef pthread_mutex_t hb_mutex_impl_t; #define HB_MUTEX_IMPL_INIT PTHREAD_MUTEX_INITIALIZER -#define hb_mutex_impl_init(M) pthread_mutex_init (M, NULL) +#define hb_mutex_impl_init(M) pthread_mutex_init (M, nullptr) #define hb_mutex_impl_lock(M) pthread_mutex_lock (M) #define hb_mutex_impl_unlock(M) pthread_mutex_unlock (M) #define hb_mutex_impl_finish(M) pthread_mutex_destroy (M) diff --git a/src/hb-object-private.hh b/src/hb-object-private.hh index 6b73ff92d..d678ae369 100644 --- a/src/hb-object-private.hh +++ b/src/hb-object-private.hh @@ -193,7 +193,7 @@ static inline void *hb_object_get_user_data (Type *obj, hb_user_data_key_t *key) { if (unlikely (!obj || hb_object_is_inert (obj))) - return NULL; + return nullptr; assert (hb_object_is_valid (obj)); return obj->header.user_data.get (key); } diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 9cd482adb..bed5eea2e 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -192,9 +192,9 @@ struct hb_sanitize_context_t : { inline hb_sanitize_context_t (void) : debug_depth (0), - start (NULL), end (NULL), + start (nullptr), end (nullptr), writable (false), edit_count (0), - blob (NULL) {} + blob (nullptr) {} inline const char *get_name (void) { return "SANITIZE"; } template @@ -214,7 +214,7 @@ struct hb_sanitize_context_t : inline void start_processing (void) { - this->start = hb_blob_get_data (this->blob, NULL); + this->start = hb_blob_get_data (this->blob, nullptr); this->end = this->start + hb_blob_get_length (this->blob); assert (this->start <= this->end); /* Must not overflow. */ this->edit_count = 0; @@ -233,8 +233,8 @@ struct hb_sanitize_context_t : this->start, this->end, this->edit_count); hb_blob_destroy (this->blob); - this->blob = NULL; - this->start = this->end = NULL; + this->blob = nullptr; + this->start = this->end = nullptr; } inline bool check_range (const void *base, unsigned int len) const @@ -349,7 +349,7 @@ struct Sanitizer } else { unsigned int edit_count = c->edit_count; if (edit_count && !c->writable) { - c->start = hb_blob_get_data_writable (blob, NULL); + c->start = hb_blob_get_data_writable (blob, nullptr); c->end = c->start + hb_blob_get_length (blob); if (c->start) { @@ -374,7 +374,7 @@ struct Sanitizer static const Type* lock_instance (hb_blob_t *blob) { hb_blob_make_immutable (blob); - const char *base = hb_blob_get_data (blob, NULL); + const char *base = hb_blob_get_data (blob, nullptr); return unlikely (!base) ? &Null(Type) : CastP (base); } }; @@ -445,7 +445,7 @@ struct hb_serialize_context_t { if (unlikely (this->ran_out_of_room || this->end - this->head < ptrdiff_t (size))) { this->ran_out_of_room = true; - return NULL; + return nullptr; } memset (this->head, 0, size); char *ret = this->head; @@ -471,7 +471,7 @@ struct hb_serialize_context_t { unsigned int size = obj.get_size (); Type *ret = this->allocate_size (size); - if (unlikely (!ret)) return NULL; + if (unlikely (!ret)) return nullptr; memcpy (ret, obj, size); return ret; } @@ -481,7 +481,7 @@ struct hb_serialize_context_t { unsigned int size = obj.min_size; assert (this->start <= (char *) &obj && (char *) &obj <= this->head && (char *) &obj + size >= this->head); - if (unlikely (!this->allocate_size (((char *) &obj) + size - this->head))) return NULL; + if (unlikely (!this->allocate_size (((char *) &obj) + size - this->head))) return nullptr; return reinterpret_cast (&obj); } @@ -490,7 +490,7 @@ struct hb_serialize_context_t { unsigned int size = obj.get_size (); assert (this->start < (char *) &obj && (char *) &obj <= this->head && (char *) &obj + size >= this->head); - if (unlikely (!this->allocate_size (((char *) &obj) + size - this->head))) return NULL; + if (unlikely (!this->allocate_size (((char *) &obj) + size - this->head))) return nullptr; return reinterpret_cast (&obj); } @@ -1073,7 +1073,7 @@ struct hb_lazy_loader_t inline void init (hb_face_t *face_) { face = face_; - instance = NULL; + instance = nullptr; } inline void fini (void) @@ -1096,7 +1096,7 @@ struct hb_lazy_loader_t p = const_cast (&OT::Null(T)); else p->init (face); - if (unlikely (!hb_atomic_ptr_cmpexch (const_cast(&instance), NULL, p))) + if (unlikely (!hb_atomic_ptr_cmpexch (const_cast(&instance), nullptr, p))) { if (p != &OT::Null(T)) p->fini (); @@ -1123,8 +1123,8 @@ struct hb_lazy_table_loader_t inline void init (hb_face_t *face_) { face = face_; - instance = NULL; - blob = NULL; + instance = nullptr; + blob = nullptr; } inline void fini (void) @@ -1140,7 +1140,7 @@ struct hb_lazy_table_loader_t { hb_blob_t *blob_ = OT::Sanitizer::sanitize (face->reference_table (T::tableTag)); p = const_cast(OT::Sanitizer::lock_instance (blob_)); - if (!hb_atomic_ptr_cmpexch (const_cast(&instance), NULL, p)) + if (!hb_atomic_ptr_cmpexch (const_cast(&instance), nullptr, p)) { hb_blob_destroy (blob_); goto retry; diff --git a/src/hb-ot-cbdt-table.hh b/src/hb-ot-cbdt-table.hh index 0a7fbf5b7..3c6855b05 100644 --- a/src/hb-ot-cbdt-table.hh +++ b/src/hb-ot-cbdt-table.hh @@ -245,7 +245,7 @@ struct IndexSubtableArray return &indexSubtablesZ[i]; } } - return NULL; + return nullptr; } protected: @@ -344,7 +344,7 @@ struct CBLC } } - return NULL; + return nullptr; } protected: diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index 3a53a1cb5..93f38c56a 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -508,7 +508,7 @@ struct cmap * unsorted subtable list. */ int result = encodingRecord./*bsearch*/lsearch (key); if (result == -1 || !encodingRecord[result].subtable) - return NULL; + return nullptr; return &(this+encodingRecord[result].subtable); } diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index a56f4c07f..06d1b8065 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -235,8 +235,8 @@ struct hb_ot_face_cbdt_accelerator_t cbdt_len = hb_blob_get_length (cbdt_blob); if (hb_blob_get_length (cblc_blob) == 0) { - cblc = NULL; - cbdt = NULL; + cblc = nullptr; + cbdt = nullptr; return; /* Not a bitmap font. */ } cblc = OT::Sanitizer::lock_instance (cblc_blob); @@ -349,8 +349,8 @@ struct hb_ot_face_cmap_accelerator_t { this->blob = OT::Sanitizer::sanitize (face->reference_table (HB_OT_TAG_cmap)); const OT::cmap *cmap = OT::Sanitizer::lock_instance (this->blob); - const OT::CmapSubtable *subtable = NULL; - const OT::CmapSubtableFormat14 *subtable_uvs = NULL; + const OT::CmapSubtable *subtable = nullptr; + const OT::CmapSubtableFormat14 *subtable_uvs = nullptr; bool symbol = false; /* 32-bit subtables. */ @@ -445,7 +445,7 @@ _hb_ot_font_create (hb_face_t *face) hb_ot_font_t *ot_font = (hb_ot_font_t *) calloc (1, sizeof (hb_ot_font_t)); if (unlikely (!ot_font)) - return NULL; + return nullptr; ot_font->cmap.init (face); ot_font->h_metrics.init (face, HB_OT_TAG_hhea, HB_OT_TAG_hmtx, HB_OT_TAG_HVAR, HB_OT_TAG_os2); @@ -563,7 +563,7 @@ hb_ot_get_font_v_extents (hb_font_t *font HB_UNUSED, return ot_font->v_metrics.has_font_extents; } -static hb_font_funcs_t *static_ot_funcs = NULL; +static hb_font_funcs_t *static_ot_funcs = nullptr; #ifdef HB_USE_ATEXIT static @@ -583,24 +583,24 @@ retry: { funcs = hb_font_funcs_create (); - hb_font_funcs_set_font_h_extents_func (funcs, hb_ot_get_font_h_extents, NULL, NULL); - hb_font_funcs_set_font_v_extents_func (funcs, hb_ot_get_font_v_extents, NULL, NULL); - hb_font_funcs_set_nominal_glyph_func (funcs, hb_ot_get_nominal_glyph, NULL, NULL); - hb_font_funcs_set_variation_glyph_func (funcs, hb_ot_get_variation_glyph, NULL, NULL); - hb_font_funcs_set_glyph_h_advance_func (funcs, hb_ot_get_glyph_h_advance, NULL, NULL); - hb_font_funcs_set_glyph_v_advance_func (funcs, hb_ot_get_glyph_v_advance, NULL, NULL); - //hb_font_funcs_set_glyph_h_origin_func (funcs, hb_ot_get_glyph_h_origin, NULL, NULL); - //hb_font_funcs_set_glyph_v_origin_func (funcs, hb_ot_get_glyph_v_origin, NULL, NULL); - //hb_font_funcs_set_glyph_h_kerning_func (funcs, hb_ot_get_glyph_h_kerning, NULL, NULL); TODO - //hb_font_funcs_set_glyph_v_kerning_func (funcs, hb_ot_get_glyph_v_kerning, NULL, NULL); - hb_font_funcs_set_glyph_extents_func (funcs, hb_ot_get_glyph_extents, NULL, NULL); - //hb_font_funcs_set_glyph_contour_point_func (funcs, hb_ot_get_glyph_contour_point, NULL, NULL); TODO - //hb_font_funcs_set_glyph_name_func (funcs, hb_ot_get_glyph_name, NULL, NULL); TODO - //hb_font_funcs_set_glyph_from_name_func (funcs, hb_ot_get_glyph_from_name, NULL, NULL); TODO + hb_font_funcs_set_font_h_extents_func (funcs, hb_ot_get_font_h_extents, nullptr, nullptr); + hb_font_funcs_set_font_v_extents_func (funcs, hb_ot_get_font_v_extents, nullptr, nullptr); + hb_font_funcs_set_nominal_glyph_func (funcs, hb_ot_get_nominal_glyph, nullptr, nullptr); + hb_font_funcs_set_variation_glyph_func (funcs, hb_ot_get_variation_glyph, nullptr, nullptr); + hb_font_funcs_set_glyph_h_advance_func (funcs, hb_ot_get_glyph_h_advance, nullptr, nullptr); + hb_font_funcs_set_glyph_v_advance_func (funcs, hb_ot_get_glyph_v_advance, nullptr, nullptr); + //hb_font_funcs_set_glyph_h_origin_func (funcs, hb_ot_get_glyph_h_origin, nullptr, nullptr); + //hb_font_funcs_set_glyph_v_origin_func (funcs, hb_ot_get_glyph_v_origin, nullptr, nullptr); + //hb_font_funcs_set_glyph_h_kerning_func (funcs, hb_ot_get_glyph_h_kerning, nullptr, nullptr); TODO + //hb_font_funcs_set_glyph_v_kerning_func (funcs, hb_ot_get_glyph_v_kerning, nullptr, nullptr); + hb_font_funcs_set_glyph_extents_func (funcs, hb_ot_get_glyph_extents, nullptr, nullptr); + //hb_font_funcs_set_glyph_contour_point_func (funcs, hb_ot_get_glyph_contour_point, nullptr, nullptr); TODO + //hb_font_funcs_set_glyph_name_func (funcs, hb_ot_get_glyph_name, nullptr, nullptr); TODO + //hb_font_funcs_set_glyph_from_name_func (funcs, hb_ot_get_glyph_from_name, nullptr, nullptr); TODO hb_font_funcs_make_immutable (funcs); - if (!hb_atomic_ptr_cmpexch (&static_ot_funcs, NULL, funcs)) { + if (!hb_atomic_ptr_cmpexch (&static_ot_funcs, nullptr, funcs)) { hb_font_funcs_destroy (funcs); goto retry; } diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index f22d990bc..ed18bd88f 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -214,7 +214,7 @@ struct LangSys } inline bool sanitize (hb_sanitize_context_t *c, - const Record::sanitize_closure_t * = NULL) const + const Record::sanitize_closure_t * = nullptr) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && featureIndex.sanitize (c)); @@ -254,7 +254,7 @@ struct Script inline const LangSys& get_default_lang_sys (void) const { return this+defaultLangSys; } inline bool sanitize (hb_sanitize_context_t *c, - const Record