Rename misc uses of "free"
In preparation for fixing https://github.com/harfbuzz/harfbuzz/issues/3044
diff --git a/src/hb-array.hh b/src/hb-array.hh
index 9af98b1..171646f 100644
--- a/src/hb-array.hh
+++ b/src/hb-array.hh
@@ -232,8 +232,8 @@
}
/* 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 <typename hb_serialize_context_t>
hb_array_t copy (hb_serialize_context_t *c) const
diff --git a/src/hb-cache.hh b/src/hb-cache.hh
index bf26d96..e617b75 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 <unsigned int key_bits, unsigned int value_bits, unsigned int cache_bits>
struct hb_cache_t
diff --git a/src/hb-common.cc b/src/hb-common.cc
index 7bb878b..ebc7e42 100644
--- a/src/hb-common.cc
+++ b/src/hb-common.cc
@@ -257,11 +257,9 @@
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 @@
};
-/* Thread-safe lock-free language list */
+/* Thread-safe lockfree language list */
static hb_atomic_ptr_t <hb_language_item_t> langs;
diff --git a/src/hb-iter.hh b/src/hb-iter.hh
index f701815..b8c4472 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 367e143..ffbbb1b 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 7851982..27f69ec 100644
--- a/src/hb-ot-glyf-table.hh
+++ b/src/hb-ot-glyf-table.hh
@@ -920,7 +920,7 @@
{
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 e983754..0c0b6b4 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -1880,7 +1880,7 @@
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 bc80586..4653420 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -1388,7 +1388,8 @@
* @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 dcf0faf..251dafc 100644
--- a/src/hb-pool.hh
+++ b/src/hb-pool.hh
@@ -41,7 +41,7 @@
{
next = nullptr;
- for (chunk_t *_ : chunks) ::free (_);
+ for (chunk_t *_ : chunks) free (_);
chunks.fini ();
}
@@ -65,7 +65,7 @@
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 f732515..42eae64 100644
--- a/src/hb-serialize.hh
+++ b/src/hb-serialize.hh
@@ -254,7 +254,7 @@
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 ec247d8..4356a81 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 0d9eadd..56f3a2f 100644
--- a/src/hb-shape-plan.cc
+++ b/src/hb-shape-plan.cc
@@ -264,7 +264,7 @@
#ifndef HB_NO_OT_SHAPE
bail3:
#endif
- shape_plan->key.free ();
+ shape_plan->key.fini ();
bail2:
free (shape_plan);
bail:
@@ -320,7 +320,7 @@
#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 6da7edb..e4779be 100644
--- a/src/hb-shape-plan.hh
+++ b/src/hb-shape-plan.hh
@@ -55,7 +55,7 @@
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 a8cc639..6f46b04 100644
--- a/src/test-repacker.cc
+++ b/src/test-repacker.cc
@@ -377,8 +377,8 @@
assert (actual == expected);
- actual.free ();
- expected.free ();
+ actual.fini ();
+ expected.fini ();
free (buffer_1);
free (buffer_2);
}
@@ -438,7 +438,7 @@
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 @@
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);
}