diff --git a/src/hb-array.hh b/src/hb-array.hh index 9af98b103..171646fff 100644 --- a/src/hb-array.hh +++ b/src/hb-array.hh @@ -232,8 +232,8 @@ struct hb_array_t : hb_iter_with_fallback_t, Type&> } /* Only call if you allocated the underlying array using malloc() or similar. */ - void free () - { ::free ((void *) arrayZ); arrayZ = nullptr; length = 0; } + void fini () + { free ((void *) arrayZ); arrayZ = nullptr; length = 0; } template hb_array_t copy (hb_serialize_context_t *c) const diff --git a/src/hb-cache.hh b/src/hb-cache.hh index bf26d96be..e617b75de 100644 --- a/src/hb-cache.hh +++ b/src/hb-cache.hh @@ -30,7 +30,7 @@ #include "hb.hh" -/* Implements a lock-free cache for int->int functions. */ +/* Implements a lockfree cache for int->int functions. */ template struct hb_cache_t diff --git a/src/hb-common.cc b/src/hb-common.cc index 7bb878b21..ebc7e426f 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -257,11 +257,9 @@ struct hb_language_item_t { bool operator == (const char *s) const { return lang_equal (lang, s); } - hb_language_item_t & operator = (const char *s) { - /* If a custom allocated is used calling strdup() pairs - badly with a call to the custom free() in fini() below. - Therefore don't call strdup(), implement its behavior. - */ + hb_language_item_t & operator = (const char *s) + { + /* We can't call strdup(), because we allow custom allocators. */ size_t len = strlen(s) + 1; lang = (hb_language_t) malloc(len); if (likely (lang)) @@ -278,7 +276,7 @@ struct hb_language_item_t { }; -/* Thread-safe lock-free language list */ +/* Thread-safe lockfree language list */ static hb_atomic_ptr_t langs; diff --git a/src/hb-iter.hh b/src/hb-iter.hh index f7018150e..b8c447263 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -46,7 +46,7 @@ * TODO Document more. * * If iterator implementation implements operator!=, then can be - * used in range-based for loop. That comes free if the iterator + * used in range-based for loop. That already happens if the iterator * is random-access. Otherwise, the range-based for loop incurs * one traversal to find end(), which can be avoided if written * as a while-style for loop, or if iterator implements a faster diff --git a/src/hb-ot-face-table-list.hh b/src/hb-ot-face-table-list.hh index 367e143fd..ffbbb1bc5 100644 --- a/src/hb-ot-face-table-list.hh +++ b/src/hb-ot-face-table-list.hh @@ -40,7 +40,7 @@ /* This lists font tables that the hb_face_t will contain and lazily * load. Don't add a table unless it's used though. This is not - * exactly free. */ + * exactly zero-cost. */ /* v--- Add new tables in the right place here. */ diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh index 7851982f7..27f69ecbc 100644 --- a/src/hb-ot-glyf-table.hh +++ b/src/hb-ot-glyf-table.hh @@ -920,7 +920,7 @@ struct glyf { if (gid >= num_glyphs) return false; - /* Making this alloc free is not that easy + /* Making this allocfree is not that easy https://github.com/harfbuzz/harfbuzz/issues/2095 mostly because of gvar handling in VF fonts, perhaps a separate path for non-VF fonts can be considered */ diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index e983754db..0c0b6b4be 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1880,7 +1880,7 @@ struct CursivePosFormat1 else pos[child].x_offset = x_offset; - /* If parent was attached to child, break them free. + /* If parent was attached to child, separate them. * https://github.com/harfbuzz/harfbuzz/issues/2469 */ if (unlikely (pos[parent].attach_chain() == -pos[child].attach_chain())) diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index bc80586ab..4653420e2 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -1388,7 +1388,8 @@ hb_ot_layout_has_substitution (hb_face_t *face) * @lookup_index: The index of the lookup to query * @glyphs: The sequence of glyphs to query for substitution * @glyphs_length: The length of the glyph sequence - * @zero_context: #hb_bool_t indicating whether substitutions should be context-free + * @zero_context: #hb_bool_t indicating whether pre-/post-context are disallowed + * in substitutions * * Tests whether a specified lookup in the specified face would * trigger a substitution on the given glyph sequence. diff --git a/src/hb-pool.hh b/src/hb-pool.hh index dcf0faf2a..251dafcec 100644 --- a/src/hb-pool.hh +++ b/src/hb-pool.hh @@ -41,7 +41,7 @@ struct hb_pool_t { next = nullptr; - for (chunk_t *_ : chunks) ::free (_); + for (chunk_t *_ : chunks) free (_); chunks.fini (); } @@ -65,7 +65,7 @@ struct hb_pool_t return obj; } - void free (T* obj) + void release (T* obj) { * (T**) obj = next; next = obj; diff --git a/src/hb-serialize.hh b/src/hb-serialize.hh index f7325152b..42eae64f3 100644 --- a/src/hb-serialize.hh +++ b/src/hb-serialize.hh @@ -254,7 +254,7 @@ struct hb_serialize_context_t current = current->next; revert (obj->head, obj->tail); obj->fini (); - object_pool.free (obj); + object_pool.release (obj); } /* Set share to false when an object is unlikely sharable with others diff --git a/src/hb-set.hh b/src/hb-set.hh index ec247d8cc..4356a81c4 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -35,7 +35,7 @@ * hb_set_t */ -/* TODO Keep a free-list so we can free pages that are completely zeroed. At that +/* TODO Keep a freelist so we can release pages that are completely zeroed. At that * point maybe also use a sentinel value for "all-1" pages? */ struct hb_set_t diff --git a/src/hb-shape-plan.cc b/src/hb-shape-plan.cc index 0d9eaddaa..56f3a2f75 100644 --- a/src/hb-shape-plan.cc +++ b/src/hb-shape-plan.cc @@ -264,7 +264,7 @@ hb_shape_plan_create2 (hb_face_t *face, #ifndef HB_NO_OT_SHAPE bail3: #endif - shape_plan->key.free (); + shape_plan->key.fini (); bail2: free (shape_plan); bail: @@ -320,7 +320,7 @@ hb_shape_plan_destroy (hb_shape_plan_t *shape_plan) #ifndef HB_NO_OT_SHAPE shape_plan->ot.fini (); #endif - shape_plan->key.free (); + shape_plan->key.fini (); free (shape_plan); } diff --git a/src/hb-shape-plan.hh b/src/hb-shape-plan.hh index 6da7edb2f..e4779bef8 100644 --- a/src/hb-shape-plan.hh +++ b/src/hb-shape-plan.hh @@ -55,7 +55,7 @@ struct hb_shape_plan_key_t unsigned int num_coords, const char * const *shaper_list); - HB_INTERNAL void free () { ::free ((void *) user_features); } + HB_INTERNAL void fini () { free ((void *) user_features); } HB_INTERNAL bool user_features_match (const hb_shape_plan_key_t *other); diff --git a/src/test-repacker.cc b/src/test-repacker.cc index a8cc6395f..6f46b0428 100644 --- a/src/test-repacker.cc +++ b/src/test-repacker.cc @@ -377,8 +377,8 @@ test_serialize () assert (actual == expected); - actual.free (); - expected.free (); + actual.fini (); + expected.fini (); free (buffer_1); free (buffer_2); } @@ -438,7 +438,7 @@ static void test_resolve_overflows_via_sort () hb_bytes_t result = out.copy_bytes (); assert (result.length == (80000 + 3 + 3 * 2)); - result.free (); + result.fini (); free (buffer); free (out_buffer); } @@ -459,7 +459,7 @@ static void test_resolve_overflows_via_duplication () hb_bytes_t result = out.copy_bytes (); assert (result.length == (10000 + 2 * 2 + 60000 + 2 + 3 * 2)); - result.free (); + result.fini (); free (buffer); free (out_buffer); }