Rename misc uses of "free"
In preparation for fixing https://github.com/harfbuzz/harfbuzz/issues/3044
This commit is contained in:
parent
7416faceeb
commit
bb48bf52a4
|
@ -232,8 +232,8 @@ struct hb_array_t : hb_iter_with_fallback_t<hb_array_t<Type>, 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 <typename hb_serialize_context_t>
|
||||
hb_array_t copy (hb_serialize_context_t *c) const
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <hb_language_item_t> langs;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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. */
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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()))
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue