diff --git a/src/hb-array.hh b/src/hb-array.hh index 171646fff..e60e03789 100644 --- a/src/hb-array.hh +++ b/src/hb-array.hh @@ -231,9 +231,9 @@ struct hb_array_t : hb_iter_with_fallback_t, Type&> && (unsigned int) (arrayZ + length - (const char *) p) >= size; } - /* Only call if you allocated the underlying array using malloc() or similar. */ + /* Only call if you allocated the underlying array using hb_malloc() or similar. */ void fini () - { free ((void *) arrayZ); arrayZ = nullptr; length = 0; } + { hb_free ((void *) arrayZ); arrayZ = nullptr; length = 0; } template hb_array_t copy (hb_serialize_context_t *c) const diff --git a/src/hb-blob.cc b/src/hb-blob.cc index 4939bf2ff..46ac5e835 100644 --- a/src/hb-blob.cc +++ b/src/hb-blob.cc @@ -265,7 +265,7 @@ hb_blob_destroy (hb_blob_t *blob) blob->fini_shallow (); - free (blob); + hb_free (blob); } /** @@ -491,7 +491,7 @@ hb_blob_t::try_make_writable () char *new_data; - new_data = (char *) malloc (this->length); + new_data = (char *) hb_malloc (this->length); if (unlikely (!new_data)) return false; @@ -502,7 +502,7 @@ hb_blob_t::try_make_writable () this->mode = HB_MEMORY_MODE_WRITABLE; this->data = new_data; this->user_data = new_data; - this->destroy = free; + this->destroy = hb_free; return true; } @@ -556,7 +556,7 @@ _hb_mapped_file_destroy (void *file_) assert (0); // If we don't have mmap we shouldn't reach here #endif - free (file); + hb_free (file); } #endif @@ -567,7 +567,7 @@ _open_resource_fork (const char *file_name, hb_mapped_file_t *file) size_t name_len = strlen (file_name); size_t len = name_len + sizeof (_PATH_RSRCFORKSPEC); - char *rsrc_name = (char *) malloc (len); + char *rsrc_name = (char *) hb_malloc (len); if (unlikely (!rsrc_name)) return -1; strncpy (rsrc_name, file_name, name_len); @@ -575,7 +575,7 @@ _open_resource_fork (const char *file_name, hb_mapped_file_t *file) sizeof (_PATH_RSRCFORKSPEC) - 1); int fd = open (rsrc_name, O_RDONLY | O_BINARY, 0); - free (rsrc_name); + hb_free (rsrc_name); if (fd != -1) { @@ -630,7 +630,7 @@ hb_blob_create_from_file_or_fail (const char *file_name) /* Adopted from glib's gmappedfile.c with Matthias Clasen and Allison Lortie permission but changed a lot to suit our need. */ #if defined(HAVE_MMAP) && !defined(HB_NO_MMAP) - hb_mapped_file_t *file = (hb_mapped_file_t *) calloc (1, sizeof (hb_mapped_file_t)); + hb_mapped_file_t *file = (hb_mapped_file_t *) hb_calloc (1, sizeof (hb_mapped_file_t)); if (unlikely (!file)) return hb_blob_get_empty (); int fd = open (file_name, O_RDONLY | O_BINARY, 0); @@ -667,15 +667,15 @@ hb_blob_create_from_file_or_fail (const char *file_name) fail: close (fd); fail_without_close: - free (file); + hb_free (file); #elif defined(_WIN32) && !defined(HB_NO_MMAP) - hb_mapped_file_t *file = (hb_mapped_file_t *) calloc (1, sizeof (hb_mapped_file_t)); + hb_mapped_file_t *file = (hb_mapped_file_t *) hb_calloc (1, sizeof (hb_mapped_file_t)); if (unlikely (!file)) return hb_blob_get_empty (); HANDLE fd; unsigned int size = strlen (file_name) + 1; - wchar_t * wchar_file_name = (wchar_t *) malloc (sizeof (wchar_t) * size); + wchar_t * wchar_file_name = (wchar_t *) hb_malloc (sizeof (wchar_t) * size); if (unlikely (!wchar_file_name)) goto fail_without_close; mbstowcs (wchar_file_name, file_name, size); #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) @@ -695,7 +695,7 @@ fail_without_close: OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED, nullptr); #endif - free (wchar_file_name); + hb_free (wchar_file_name); if (unlikely (fd == INVALID_HANDLE_VALUE)) goto fail_without_close; @@ -727,14 +727,14 @@ fail_without_close: fail: CloseHandle (fd); fail_without_close: - free (file); + hb_free (file); #endif /* The following tries to read a file without knowing its size beforehand It's used as a fallback for systems without mmap or to read from pipes */ unsigned long len = 0, allocated = BUFSIZ * 16; - char *data = (char *) malloc (allocated); + char *data = (char *) hb_malloc (allocated); if (unlikely (!data)) return nullptr; FILE *fp = fopen (file_name, "rb"); @@ -748,7 +748,7 @@ fail_without_close: /* Don't allocate and go more than ~536MB, our mmap reader still can cover files like that but lets limit our fallback reader */ if (unlikely (allocated > (2 << 28))) goto fread_fail; - char *new_data = (char *) realloc (data, allocated); + char *new_data = (char *) hb_realloc (data, allocated); if (unlikely (!new_data)) goto fread_fail; data = new_data; } @@ -766,12 +766,12 @@ fail_without_close: fclose (fp); return hb_blob_create_or_fail (data, len, HB_MEMORY_MODE_WRITABLE, data, - (hb_destroy_func_t) free); + (hb_destroy_func_t) hb_free); fread_fail: fclose (fp); fread_fail_without_close: - free (data); + hb_free (data); return nullptr; } #endif /* !HB_NO_OPEN */ diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index b125e1cea..216ace0c4 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -136,8 +136,8 @@ hb_buffer_t::enlarge (unsigned int size) if (unlikely (hb_unsigned_mul_overflows (new_allocated, sizeof (info[0])))) goto done; - new_pos = (hb_glyph_position_t *) realloc (pos, new_allocated * sizeof (pos[0])); - new_info = (hb_glyph_info_t *) realloc (info, new_allocated * sizeof (info[0])); + new_pos = (hb_glyph_position_t *) hb_realloc (pos, new_allocated * sizeof (pos[0])); + new_info = (hb_glyph_info_t *) hb_realloc (info, new_allocated * sizeof (info[0])); done: if (unlikely (!new_pos || !new_info)) @@ -717,14 +717,14 @@ hb_buffer_destroy (hb_buffer_t *buffer) hb_unicode_funcs_destroy (buffer->unicode); - free (buffer->info); - free (buffer->pos); + hb_free (buffer->info); + hb_free (buffer->pos); #ifndef HB_NO_BUFFER_MESSAGE if (buffer->message_destroy) buffer->message_destroy (buffer->message_data); #endif - free (buffer); + hb_free (buffer); } /** diff --git a/src/hb-common.cc b/src/hb-common.cc index ebc7e426f..cbba1a794 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -261,7 +261,7 @@ struct hb_language_item_t { { /* We can't call strdup(), because we allow custom allocators. */ size_t len = strlen(s) + 1; - lang = (hb_language_t) malloc(len); + lang = (hb_language_t) hb_malloc(len); if (likely (lang)) { memcpy((unsigned char *) lang, s, len); @@ -272,7 +272,7 @@ struct hb_language_item_t { return *this; } - void fini () { free ((void *) lang); } + void fini () { hb_free ((void *) lang); } }; @@ -292,7 +292,7 @@ retry: while (first_lang) { hb_language_item_t *next = first_lang->next; first_lang->fini (); - free (first_lang); + hb_free (first_lang); first_lang = next; } } @@ -309,21 +309,21 @@ retry: return lang; /* Not found; allocate one. */ - hb_language_item_t *lang = (hb_language_item_t *) calloc (1, sizeof (hb_language_item_t)); + hb_language_item_t *lang = (hb_language_item_t *) hb_calloc (1, sizeof (hb_language_item_t)); if (unlikely (!lang)) return nullptr; lang->next = first_lang; *lang = key; if (unlikely (!lang->lang)) { - free (lang); + hb_free (lang); return nullptr; } if (unlikely (!langs.cmpexch (first_lang, lang))) { lang->fini (); - free (lang); + hb_free (lang); goto retry; } diff --git a/src/hb-directwrite.cc b/src/hb-directwrite.cc index 937e2f6d2..a1e57b00f 100644 --- a/src/hb-directwrite.cc +++ b/src/hb-directwrite.cc @@ -921,7 +921,7 @@ _hb_directwrite_table_data_release (void *data) { _hb_directwrite_font_table_context *context = (_hb_directwrite_font_table_context *) data; context->face->ReleaseFontTable (context->table_context); - free (context); + hb_free (context); } static hb_blob_t * @@ -942,7 +942,7 @@ _hb_directwrite_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void * return nullptr; } - _hb_directwrite_font_table_context *context = (_hb_directwrite_font_table_context *) malloc (sizeof (_hb_directwrite_font_table_context)); + _hb_directwrite_font_table_context *context = (_hb_directwrite_font_table_context *) hb_malloc (sizeof (_hb_directwrite_font_table_context)); context->face = dw_face; context->table_context = table_context; diff --git a/src/hb-draw.cc b/src/hb-draw.cc index 1a5f9c8c6..c0af6ce01 100644 --- a/src/hb-draw.cc +++ b/src/hb-draw.cc @@ -191,7 +191,7 @@ hb_draw_funcs_destroy (hb_draw_funcs_t *funcs) { if (!hb_object_destroy (funcs)) return; - free (funcs); + hb_free (funcs); } /** diff --git a/src/hb-face.cc b/src/hb-face.cc index 60f9f5c94..867c172a1 100644 --- a/src/hb-face.cc +++ b/src/hb-face.cc @@ -150,7 +150,7 @@ _hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index) { hb_face_for_data_closure_t *closure; - closure = (hb_face_for_data_closure_t *) calloc (1, sizeof (hb_face_for_data_closure_t)); + closure = (hb_face_for_data_closure_t *) hb_calloc (1, sizeof (hb_face_for_data_closure_t)); if (unlikely (!closure)) return nullptr; @@ -166,7 +166,7 @@ _hb_face_for_data_closure_destroy (void *data) hb_face_for_data_closure_t *closure = (hb_face_for_data_closure_t *) data; hb_blob_destroy (closure->blob); - free (closure); + hb_free (closure); } static hb_blob_t * @@ -281,7 +281,7 @@ hb_face_destroy (hb_face_t *face) { hb_face_t::plan_node_t *next = node->next; hb_shape_plan_destroy (node->shape_plan); - free (node); + hb_free (node); node = next; } @@ -291,7 +291,7 @@ hb_face_destroy (hb_face_t *face) if (face->destroy) face->destroy (face->user_data); - free (face); + hb_free (face); } /** @@ -642,7 +642,7 @@ struct hb_face_builder_data_t static hb_face_builder_data_t * _hb_face_builder_data_create () { - hb_face_builder_data_t *data = (hb_face_builder_data_t *) calloc (1, sizeof (hb_face_builder_data_t)); + hb_face_builder_data_t *data = (hb_face_builder_data_t *) hb_calloc (1, sizeof (hb_face_builder_data_t)); if (unlikely (!data)) return nullptr; @@ -661,7 +661,7 @@ _hb_face_builder_data_destroy (void *user_data) data->tables.fini (); - free (data); + hb_free (data); } static hb_blob_t * @@ -674,7 +674,7 @@ _hb_face_builder_data_reference_blob (hb_face_builder_data_t *data) for (unsigned int i = 0; i < table_count; i++) face_length += hb_ceil_to_4 (hb_blob_get_length (data->tables[i].blob)); - char *buf = (char *) malloc (face_length); + char *buf = (char *) hb_malloc (face_length); if (unlikely (!buf)) return nullptr; @@ -691,11 +691,11 @@ _hb_face_builder_data_reference_blob (hb_face_builder_data_t *data) if (unlikely (!ret)) { - free (buf); + hb_free (buf); return nullptr; } - return hb_blob_create (buf, face_length, HB_MEMORY_MODE_WRITABLE, buf, free); + return hb_blob_create (buf, face_length, HB_MEMORY_MODE_WRITABLE, buf, hb_free); } static hb_blob_t * diff --git a/src/hb-font.cc b/src/hb-font.cc index 37a0e7fe8..822d1b771 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -620,7 +620,7 @@ hb_font_funcs_destroy (hb_font_funcs_t *ffuncs) HB_FONT_FUNCS_IMPLEMENT_CALLBACKS #undef HB_FONT_FUNC_IMPLEMENT - free (ffuncs); + hb_free (ffuncs); } /** @@ -1544,8 +1544,8 @@ _hb_font_adopt_var_coords (hb_font_t *font, float *design_coords, unsigned int coords_length) { - free (font->coords); - free (font->design_coords); + hb_free (font->coords); + hb_free (font->design_coords); font->coords = coords; font->design_coords = design_coords; @@ -1586,8 +1586,8 @@ hb_font_create_sub_font (hb_font_t *parent) unsigned int num_coords = parent->num_coords; if (num_coords) { - int *coords = (int *) calloc (num_coords, sizeof (parent->coords[0])); - float *design_coords = (float *) calloc (num_coords, sizeof (parent->design_coords[0])); + int *coords = (int *) hb_calloc (num_coords, sizeof (parent->coords[0])); + float *design_coords = (float *) hb_calloc (num_coords, sizeof (parent->design_coords[0])); if (likely (coords && design_coords)) { memcpy (coords, parent->coords, num_coords * sizeof (parent->coords[0])); @@ -1596,8 +1596,8 @@ hb_font_create_sub_font (hb_font_t *parent) } else { - free (coords); - free (design_coords); + hb_free (coords); + hb_free (design_coords); } } @@ -1659,10 +1659,10 @@ hb_font_destroy (hb_font_t *font) hb_face_destroy (font->face); hb_font_funcs_destroy (font->klass); - free (font->coords); - free (font->design_coords); + hb_free (font->coords); + hb_free (font->design_coords); - free (font); + hb_free (font); } /** @@ -2054,13 +2054,13 @@ hb_font_set_variations (hb_font_t *font, unsigned int coords_length = hb_ot_var_get_axis_count (font->face); - int *normalized = coords_length ? (int *) calloc (coords_length, sizeof (int)) : nullptr; - float *design_coords = coords_length ? (float *) calloc (coords_length, sizeof (float)) : nullptr; + int *normalized = coords_length ? (int *) hb_calloc (coords_length, sizeof (int)) : nullptr; + float *design_coords = coords_length ? (float *) hb_calloc (coords_length, sizeof (float)) : nullptr; if (unlikely (coords_length && !(normalized && design_coords))) { - free (normalized); - free (design_coords); + hb_free (normalized); + hb_free (design_coords); return; } @@ -2100,13 +2100,13 @@ hb_font_set_var_coords_design (hb_font_t *font, if (hb_object_is_immutable (font)) return; - int *normalized = coords_length ? (int *) calloc (coords_length, sizeof (int)) : nullptr; - float *design_coords = coords_length ? (float *) calloc (coords_length, sizeof (float)) : nullptr; + int *normalized = coords_length ? (int *) hb_calloc (coords_length, sizeof (int)) : nullptr; + float *design_coords = coords_length ? (float *) hb_calloc (coords_length, sizeof (float)) : nullptr; if (unlikely (coords_length && !(normalized && design_coords))) { - free (normalized); - free (design_coords); + hb_free (normalized); + hb_free (design_coords); return; } @@ -2135,13 +2135,13 @@ hb_font_set_var_named_instance (hb_font_t *font, unsigned int coords_length = hb_ot_var_named_instance_get_design_coords (font->face, instance_index, nullptr, nullptr); - float *coords = coords_length ? (float *) calloc (coords_length, sizeof (float)) : nullptr; + float *coords = coords_length ? (float *) hb_calloc (coords_length, sizeof (float)) : nullptr; if (unlikely (coords_length && !coords)) return; hb_ot_var_named_instance_get_design_coords (font->face, instance_index, &coords_length, coords); hb_font_set_var_coords_design (font, coords, coords_length); - free (coords); + hb_free (coords); } /** @@ -2165,15 +2165,15 @@ hb_font_set_var_coords_normalized (hb_font_t *font, if (hb_object_is_immutable (font)) return; - int *copy = coords_length ? (int *) calloc (coords_length, sizeof (coords[0])) : nullptr; - int *unmapped = coords_length ? (int *) calloc (coords_length, sizeof (coords[0])) : nullptr; - float *design_coords = coords_length ? (float *) calloc (coords_length, sizeof (design_coords[0])) : nullptr; + int *copy = coords_length ? (int *) hb_calloc (coords_length, sizeof (coords[0])) : nullptr; + int *unmapped = coords_length ? (int *) hb_calloc (coords_length, sizeof (coords[0])) : nullptr; + float *design_coords = coords_length ? (float *) hb_calloc (coords_length, sizeof (design_coords[0])) : nullptr; if (unlikely (coords_length && !(copy && unmapped && design_coords))) { - free (copy); - free (unmapped); - free (design_coords); + hb_free (copy); + hb_free (unmapped); + hb_free (design_coords); return; } @@ -2187,7 +2187,7 @@ hb_font_set_var_coords_normalized (hb_font_t *font, font->face->table.avar->unmap_coords (unmapped, coords_length); for (unsigned int i = 0; i < coords_length; ++i) design_coords[i] = font->face->table.fvar->unnormalize_axis_value (i, unmapped[i]); - free (unmapped); + hb_free (unmapped); _hb_font_adopt_var_coords (font, copy, design_coords, coords_length); } @@ -2267,7 +2267,7 @@ trampoline_create (FuncType func, { typedef hb_trampoline_t trampoline_t; - trampoline_t *trampoline = (trampoline_t *) calloc (1, sizeof (trampoline_t)); + trampoline_t *trampoline = (trampoline_t *) hb_calloc (1, sizeof (trampoline_t)); if (unlikely (!trampoline)) return nullptr; @@ -2296,7 +2296,7 @@ trampoline_destroy (void *user_data) if (closure->destroy) closure->destroy (closure->user_data); - free (closure); + hb_free (closure); } typedef hb_trampoline_t hb_font_get_glyph_trampoline_t; diff --git a/src/hb-ft.cc b/src/hb-ft.cc index b82c1a67b..a6beb9f0f 100644 --- a/src/hb-ft.cc +++ b/src/hb-ft.cc @@ -91,7 +91,7 @@ struct hb_ft_font_t static hb_ft_font_t * _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)); + hb_ft_font_t *ft_font = (hb_ft_font_t *) hb_calloc (1, sizeof (hb_ft_font_t)); if (unlikely (!ft_font)) return nullptr; ft_font->lock.init (); @@ -125,7 +125,7 @@ _hb_ft_font_destroy (void *data) ft_font->lock.fini (); - free (ft_font); + hb_free (ft_font); } /** @@ -642,20 +642,20 @@ _hb_ft_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data if (error) return nullptr; - buffer = (FT_Byte *) malloc (length); + buffer = (FT_Byte *) hb_malloc (length); if (!buffer) return nullptr; error = FT_Load_Sfnt_Table (ft_face, tag, 0, buffer, &length); if (error) { - free (buffer); + hb_free (buffer); return nullptr; } return hb_blob_create ((const char *) buffer, length, HB_MEMORY_MODE_WRITABLE, - buffer, free); + buffer, hb_free); } /** @@ -846,8 +846,8 @@ hb_ft_font_changed (hb_font_t *font) 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)); - int *coords = (int *) calloc (mm_var->num_axis, sizeof (int)); + FT_Fixed *ft_coords = (FT_Fixed *) hb_calloc (mm_var->num_axis, sizeof (FT_Fixed)); + int *coords = (int *) hb_calloc (mm_var->num_axis, sizeof (int)); if (coords && ft_coords) { if (!FT_Get_Var_Blend_Coordinates (ft_face, mm_var->num_axis, ft_coords)) @@ -866,12 +866,12 @@ hb_ft_font_changed (hb_font_t *font) hb_font_set_var_coords_normalized (font, nullptr, 0); } } - free (coords); - free (ft_coords); + hb_free (coords); + hb_free (ft_coords); #ifdef HAVE_FT_DONE_MM_VAR FT_Done_MM_Var (ft_face->glyph->library, mm_var); #else - free (mm_var); + hb_free (mm_var); #endif } #endif @@ -1020,13 +1020,13 @@ hb_ft_font_set_funcs (hb_font_t *font) const int *coords = hb_font_get_var_coords_normalized (font, &num_coords); if (num_coords) { - FT_Fixed *ft_coords = (FT_Fixed *) calloc (num_coords, sizeof (FT_Fixed)); + FT_Fixed *ft_coords = (FT_Fixed *) hb_calloc (num_coords, sizeof (FT_Fixed)); if (ft_coords) { for (unsigned int i = 0; i < num_coords; i++) ft_coords[i] = coords[i] * 4; FT_Set_Var_Blend_Coordinates (ft_face, num_coords, ft_coords); - free (ft_coords); + hb_free (ft_coords); } } #endif diff --git a/src/hb-gdi.cc b/src/hb-gdi.cc index dc4659c7f..8e7589bea 100644 --- a/src/hb-gdi.cc +++ b/src/hb-gdi.cc @@ -50,16 +50,16 @@ _hb_gdi_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_dat length = GetFontData (hdc, hb_uint32_swap (tag), 0, buffer, length); if (unlikely (length == GDI_ERROR)) goto fail_with_releasedc; - buffer = (char *) malloc (length); + buffer = (char *) hb_malloc (length); if (unlikely (!buffer)) goto fail_with_releasedc; length = GetFontData (hdc, hb_uint32_swap (tag), 0, buffer, length); if (unlikely (length == GDI_ERROR)) goto fail_with_releasedc_and_free; ReleaseDC (nullptr, hdc); - return hb_blob_create ((const char *) buffer, length, HB_MEMORY_MODE_WRITABLE, buffer, free); + return hb_blob_create ((const char *) buffer, length, HB_MEMORY_MODE_WRITABLE, buffer, hb_free); fail_with_releasedc_and_free: - free (buffer); + hb_free (buffer); fail_with_releasedc: ReleaseDC (nullptr, hdc); fail: diff --git a/src/hb-gobject-structs.cc b/src/hb-gobject-structs.cc index 7c46e2640..540b11f91 100644 --- a/src/hb-gobject-structs.cc +++ b/src/hb-gobject-structs.cc @@ -80,12 +80,12 @@ hb_gobject_##name##_get_type () \ #define HB_DEFINE_VALUE_TYPE(name) \ 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)); \ + hb_##name##_t *c = (hb_##name##_t *) hb_calloc (1, sizeof (hb_##name##_t)); \ if (unlikely (!c)) return nullptr; \ *c = *l; \ return c; \ } \ - static void _hb_##name##_destroy (hb_##name##_t *l) { free (l); } \ + static void _hb_##name##_destroy (hb_##name##_t *l) { hb_free (l); } \ HB_DEFINE_BOXED_TYPE (name, _hb_##name##_reference, _hb_##name##_destroy) HB_DEFINE_OBJECT_TYPE (buffer) diff --git a/src/hb-graphite2.cc b/src/hb-graphite2.cc index 2123c8216..209207f1e 100644 --- a/src/hb-graphite2.cc +++ b/src/hb-graphite2.cc @@ -88,7 +88,7 @@ static const void *hb_graphite2_get_table (const void *data, unsigned int tag, s { blob = face_data->face->reference_table (tag); - hb_graphite2_tablelist_t *p = (hb_graphite2_tablelist_t *) calloc (1, sizeof (hb_graphite2_tablelist_t)); + hb_graphite2_tablelist_t *p = (hb_graphite2_tablelist_t *) hb_calloc (1, sizeof (hb_graphite2_tablelist_t)); if (unlikely (!p)) { hb_blob_destroy (blob); return nullptr; @@ -123,7 +123,7 @@ _hb_graphite2_shaper_face_data_create (hb_face_t *face) } hb_blob_destroy (silf_blob); - hb_graphite2_face_data_t *data = (hb_graphite2_face_data_t *) calloc (1, sizeof (hb_graphite2_face_data_t)); + hb_graphite2_face_data_t *data = (hb_graphite2_face_data_t *) hb_calloc (1, sizeof (hb_graphite2_face_data_t)); if (unlikely (!data)) return nullptr; @@ -132,7 +132,7 @@ _hb_graphite2_shaper_face_data_create (hb_face_t *face) data->grface = gr_make_face_with_ops (data, &ops, gr_face_preloadAll); if (unlikely (!data->grface)) { - free (data); + hb_free (data); return nullptr; } @@ -149,12 +149,12 @@ _hb_graphite2_shaper_face_data_destroy (hb_graphite2_face_data_t *data) hb_graphite2_tablelist_t *old = tlist; hb_blob_destroy (tlist->blob); tlist = tlist->next; - free (old); + hb_free (old); } gr_face_destroy (data->grface); - free (data); + hb_free (data); } /** diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh index 3bd5a979b..010c2570d 100644 --- a/src/hb-machinery.hh +++ b/src/hb-machinery.hh @@ -242,14 +242,14 @@ struct hb_lazy_loader_t : hb_data_wrapper_t static const Stored* get_null () { return &Null (Stored); } static Stored *create (Data *data) { - Stored *p = (Stored *) calloc (1, sizeof (Stored)); + Stored *p = (Stored *) hb_calloc (1, sizeof (Stored)); if (likely (p)) p->init (data); return p; } static Stored *create () { - Stored *p = (Stored *) calloc (1, sizeof (Stored)); + Stored *p = (Stored *) hb_calloc (1, sizeof (Stored)); if (likely (p)) p->init (); return p; @@ -257,7 +257,7 @@ struct hb_lazy_loader_t : hb_data_wrapper_t static void destroy (Stored *p) { p->fini (); - free (p); + hb_free (p); } // private: diff --git a/src/hb-map.cc b/src/hb-map.cc index f115da2bb..6757535b7 100644 --- a/src/hb-map.cc +++ b/src/hb-map.cc @@ -109,7 +109,7 @@ hb_map_destroy (hb_map_t *map) map->fini_shallow (); - free (map); + hb_free (map); } /** diff --git a/src/hb-map.hh b/src/hb-map.hh index ab9c17eb1..5f1d676fe 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh @@ -85,7 +85,7 @@ struct hb_hashmap_t } void fini_shallow () { - free (items); + hb_free (items); items = nullptr; population = occupancy = 0; } @@ -109,7 +109,7 @@ struct hb_hashmap_t unsigned int power = hb_bit_storage (population * 2 + 8); unsigned int new_size = 1u << power; - item_t *new_items = (item_t *) malloc ((size_t) new_size * sizeof (item_t)); + item_t *new_items = (item_t *) hb_malloc ((size_t) new_size * sizeof (item_t)); if (unlikely (!new_items)) { successful = false; @@ -135,7 +135,7 @@ struct hb_hashmap_t old_items[i].hash, old_items[i].value); - free (old_items); + hb_free (old_items); return true; } diff --git a/src/hb-object.hh b/src/hb-object.hh index f3048b1c3..64abb0ce1 100644 --- a/src/hb-object.hh +++ b/src/hb-object.hh @@ -217,7 +217,7 @@ static inline void hb_object_trace (const Type *obj, const char *function) template static inline Type *hb_object_create () { - Type *obj = (Type *) calloc (1, sizeof (Type)); + Type *obj = (Type *) hb_calloc (1, sizeof (Type)); if (unlikely (!obj)) return obj; @@ -284,7 +284,7 @@ static inline void hb_object_fini (Type *obj) if (user_data) { user_data->fini (); - free (user_data); + hb_free (user_data); user_data = nullptr; } } @@ -303,14 +303,14 @@ retry: hb_user_data_array_t *user_data = obj->header.user_data.get (); if (unlikely (!user_data)) { - user_data = (hb_user_data_array_t *) calloc (sizeof (hb_user_data_array_t), 1); + user_data = (hb_user_data_array_t *) hb_calloc (sizeof (hb_user_data_array_t), 1); if (unlikely (!user_data)) return false; user_data->init (); if (unlikely (!obj->header.user_data.cmpexch (nullptr, user_data))) { user_data->fini (); - free (user_data); + hb_free (user_data); goto retry; } } diff --git a/src/hb-ot-color-cbdt-table.hh b/src/hb-ot-color-cbdt-table.hh index 265d8309d..6c31d1b53 100644 --- a/src/hb-ot-color-cbdt-table.hh +++ b/src/hb-ot-color-cbdt-table.hh @@ -738,7 +738,7 @@ struct CBLC cbdt_prime->length, HB_MEMORY_MODE_WRITABLE, cbdt_prime->arrayZ, - free); + hb_free); cbdt_prime->init (); // Leak arrayZ to the blob. bool ret = c->plan->add_table (HB_OT_TAG_CBDT, cbdt_prime_blob); hb_blob_destroy (cbdt_prime_blob); diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh index 27f69ecbc..229b59b9a 100644 --- a/src/hb-ot-glyf-table.hh +++ b/src/hb-ot-glyf-table.hh @@ -98,7 +98,7 @@ struct glyf unsigned num_offsets = padded_offsets.len () + 1; bool use_short_loca = max_offset < 0x1FFFF; unsigned entry_size = use_short_loca ? 2 : 4; - char *loca_prime_data = (char *) calloc (entry_size, num_offsets); + char *loca_prime_data = (char *) hb_calloc (entry_size, num_offsets); if (unlikely (!loca_prime_data)) return false; @@ -115,7 +115,7 @@ struct glyf entry_size * num_offsets, HB_MEMORY_MODE_WRITABLE, loca_prime_data, - free); + hb_free); bool result = plan->add_table (HB_OT_TAG_loca, loca_blob) && _add_head_and_set_loca_version (plan, use_short_loca); diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 926b14465..c17bf92aa 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -3786,7 +3786,7 @@ struct GSUBGPOS this->lookup_count = table->get_lookup_count (); - this->accels = (hb_ot_layout_lookup_accelerator_t *) calloc (this->lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t)); + this->accels = (hb_ot_layout_lookup_accelerator_t *) hb_calloc (this->lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t)); if (unlikely (!this->accels)) { this->lookup_count = 0; @@ -3802,7 +3802,7 @@ struct GSUBGPOS { for (unsigned int i = 0; i < this->lookup_count; i++) this->accels[i].fini (); - free (this->accels); + hb_free (this->accels); this->table.destroy (); } diff --git a/src/hb-ot-name-table.hh b/src/hb-ot-name-table.hh index 5c5c58eac..dec4d1213 100644 --- a/src/hb-ot-name-table.hh +++ b/src/hb-ot-name-table.hh @@ -214,7 +214,7 @@ struct name this->format = 0; this->count = it.len (); - NameRecord *name_records = (NameRecord *) calloc (it.len (), NameRecord::static_size); + NameRecord *name_records = (NameRecord *) hb_calloc (it.len (), NameRecord::static_size); if (unlikely (!name_records)) return_trace (false); hb_array_t records (name_records, it.len ()); @@ -228,7 +228,7 @@ struct name records.qsort (); c->copy_all (records, src_string_pool); - free (records.arrayZ); + hb_free (records.arrayZ); if (unlikely (c->ran_out_of_room ())) return_trace (false); diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh index d14626494..33d10a931 100644 --- a/src/hb-ot-post-table.hh +++ b/src/hb-ot-post-table.hh @@ -117,7 +117,7 @@ struct post void fini () { index_to_offset.fini (); - free (gids_sorted_by_name.get ()); + hb_free (gids_sorted_by_name.get ()); table.destroy (); } @@ -148,7 +148,7 @@ struct post if (unlikely (!gids)) { - gids = (uint16_t *) malloc (count * sizeof (gids[0])); + gids = (uint16_t *) hb_malloc (count * sizeof (gids[0])); if (unlikely (!gids)) return false; /* Anything better?! */ @@ -158,7 +158,7 @@ struct post if (unlikely (!gids_sorted_by_name.cmpexch (nullptr, gids))) { - free (gids); + hb_free (gids); goto retry; } } diff --git a/src/hb-ot-shape-complex-arabic-fallback.hh b/src/hb-ot-shape-complex-arabic-fallback.hh index a04011902..2b3b134ae 100644 --- a/src/hb-ot-shape-complex-arabic-fallback.hh +++ b/src/hb-ot-shape-complex-arabic-fallback.hh @@ -290,7 +290,7 @@ static arabic_fallback_plan_t * arabic_fallback_plan_create (const hb_ot_shape_plan_t *plan, hb_font_t *font) { - arabic_fallback_plan_t *fallback_plan = (arabic_fallback_plan_t *) calloc (1, sizeof (arabic_fallback_plan_t)); + arabic_fallback_plan_t *fallback_plan = (arabic_fallback_plan_t *) hb_calloc (1, sizeof (arabic_fallback_plan_t)); if (unlikely (!fallback_plan)) return const_cast (&Null (arabic_fallback_plan_t)); @@ -308,7 +308,7 @@ arabic_fallback_plan_create (const hb_ot_shape_plan_t *plan, return fallback_plan; assert (fallback_plan->num_lookups == 0); - free (fallback_plan); + hb_free (fallback_plan); return const_cast (&Null (arabic_fallback_plan_t)); } @@ -323,10 +323,10 @@ arabic_fallback_plan_destroy (arabic_fallback_plan_t *fallback_plan) { fallback_plan->accel_array[i].fini (); if (fallback_plan->free_lookups) - free (fallback_plan->lookup_array[i]); + hb_free (fallback_plan->lookup_array[i]); } - free (fallback_plan); + hb_free (fallback_plan); } static void diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index 1f244f940..1f8c1410f 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -259,7 +259,7 @@ struct arabic_shape_plan_t void * data_create_arabic (const hb_ot_shape_plan_t *plan) { - arabic_shape_plan_t *arabic_plan = (arabic_shape_plan_t *) calloc (1, sizeof (arabic_shape_plan_t)); + arabic_shape_plan_t *arabic_plan = (arabic_shape_plan_t *) hb_calloc (1, sizeof (arabic_shape_plan_t)); if (unlikely (!arabic_plan)) return nullptr; @@ -282,7 +282,7 @@ data_destroy_arabic (void *data) arabic_fallback_plan_destroy (arabic_plan->fallback_plan); - free (data); + hb_free (data); } static void diff --git a/src/hb-ot-shape-complex-hangul.cc b/src/hb-ot-shape-complex-hangul.cc index dbedd6af0..0d84a76b8 100644 --- a/src/hb-ot-shape-complex-hangul.cc +++ b/src/hb-ot-shape-complex-hangul.cc @@ -80,7 +80,7 @@ struct hangul_shape_plan_t static void * data_create_hangul (const hb_ot_shape_plan_t *plan) { - hangul_shape_plan_t *hangul_plan = (hangul_shape_plan_t *) calloc (1, sizeof (hangul_shape_plan_t)); + hangul_shape_plan_t *hangul_plan = (hangul_shape_plan_t *) hb_calloc (1, sizeof (hangul_shape_plan_t)); if (unlikely (!hangul_plan)) return nullptr; @@ -93,7 +93,7 @@ data_create_hangul (const hb_ot_shape_plan_t *plan) static void data_destroy_hangul (void *data) { - free (data); + hb_free (data); } /* Constants for algorithmic hangul syllable [de]composition. */ diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index 0594f3135..aff615f06 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -257,7 +257,7 @@ struct indic_shape_plan_t static void * data_create_indic (const hb_ot_shape_plan_t *plan) { - indic_shape_plan_t *indic_plan = (indic_shape_plan_t *) calloc (1, sizeof (indic_shape_plan_t)); + indic_shape_plan_t *indic_plan = (indic_shape_plan_t *) hb_calloc (1, sizeof (indic_shape_plan_t)); if (unlikely (!indic_plan)) return nullptr; @@ -300,7 +300,7 @@ data_create_indic (const hb_ot_shape_plan_t *plan) static void data_destroy_indic (void *data) { - free (data); + hb_free (data); } static indic_position_t diff --git a/src/hb-ot-shape-complex-khmer.cc b/src/hb-ot-shape-complex-khmer.cc index dddba142a..38f57e34c 100644 --- a/src/hb-ot-shape-complex-khmer.cc +++ b/src/hb-ot-shape-complex-khmer.cc @@ -147,7 +147,7 @@ struct khmer_shape_plan_t static void * data_create_khmer (const hb_ot_shape_plan_t *plan) { - khmer_shape_plan_t *khmer_plan = (khmer_shape_plan_t *) calloc (1, sizeof (khmer_shape_plan_t)); + khmer_shape_plan_t *khmer_plan = (khmer_shape_plan_t *) hb_calloc (1, sizeof (khmer_shape_plan_t)); if (unlikely (!khmer_plan)) return nullptr; @@ -161,7 +161,7 @@ data_create_khmer (const hb_ot_shape_plan_t *plan) static void data_destroy_khmer (void *data) { - free (data); + hb_free (data); } static void diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc index 0d0b7e771..70e35f5db 100644 --- a/src/hb-ot-shape-complex-use.cc +++ b/src/hb-ot-shape-complex-use.cc @@ -154,7 +154,7 @@ struct use_shape_plan_t static void * data_create_use (const hb_ot_shape_plan_t *plan) { - use_shape_plan_t *use_plan = (use_shape_plan_t *) calloc (1, sizeof (use_shape_plan_t)); + use_shape_plan_t *use_plan = (use_shape_plan_t *) hb_calloc (1, sizeof (use_shape_plan_t)); if (unlikely (!use_plan)) return nullptr; @@ -165,7 +165,7 @@ data_create_use (const hb_ot_shape_plan_t *plan) use_plan->arabic_plan = (arabic_shape_plan_t *) data_create_arabic (plan); if (unlikely (!use_plan->arabic_plan)) { - free (use_plan); + hb_free (use_plan); return nullptr; } } @@ -181,7 +181,7 @@ data_destroy_use (void *data) if (use_plan->arabic_plan) data_destroy_arabic (use_plan->arabic_plan); - free (data); + hb_free (data); } static void diff --git a/src/hb-ot-tag.cc b/src/hb-ot-tag.cc index fc145a41f..1837063af 100644 --- a/src/hb-ot-tag.cc +++ b/src/hb-ot-tag.cc @@ -522,7 +522,7 @@ hb_ot_tags_to_script_and_language (hb_tag_t script_tag, unsigned char *buf; const char *lang_str = hb_language_to_string (*language); size_t len = strlen (lang_str); - buf = (unsigned char *) malloc (len + 16); + buf = (unsigned char *) hb_malloc (len + 16); if (unlikely (!buf)) { *language = nullptr; @@ -544,7 +544,7 @@ hb_ot_tags_to_script_and_language (hb_tag_t script_tag, for (shift = 28; shift >= 0; shift -= 4) buf[len++] = TOHEX (script_tag >> shift); *language = hb_language_from_string ((char *) buf, len); - free (buf); + hb_free (buf); } } } diff --git a/src/hb-pool.hh b/src/hb-pool.hh index 251dafcec..dcf8f6627 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) hb_free (_); chunks.fini (); } @@ -51,7 +51,7 @@ struct hb_pool_t if (unlikely (!next)) { if (unlikely (!chunks.alloc (chunks.length + 1))) return nullptr; - chunk_t *chunk = (chunk_t *) calloc (1, sizeof (chunk_t)); + chunk_t *chunk = (chunk_t *) hb_calloc (1, sizeof (chunk_t)); if (unlikely (!chunk)) return nullptr; chunks.push (chunk); next = chunk->thread (); diff --git a/src/hb-repacker.hh b/src/hb-repacker.hh index e553bc622..b02128b5c 100644 --- a/src/hb-repacker.hh +++ b/src/hb-repacker.hh @@ -102,7 +102,7 @@ struct graph_t { fini (); unsigned size = object.tail - object.head; - head = (char*) malloc (size); + head = (char*) hb_malloc (size); if (!head) return false; memcpy (head, object.head, size); @@ -116,7 +116,7 @@ struct graph_t void fini () { if (!head) return; - free (head); + hb_free (head); head = nullptr; } }; diff --git a/src/hb-serialize.hh b/src/hb-serialize.hh index 42eae64f3..63455072e 100644 --- a/src/hb-serialize.hh +++ b/src/hb-serialize.hh @@ -547,11 +547,11 @@ struct hb_serialize_context_t unsigned int len = (this->head - this->start) + (this->end - this->tail); - // If len is zero don't malloc as the memory won't get properly + // If len is zero don't hb_malloc as the memory won't get properly // cleaned up later. if (!len) return hb_bytes_t (); - char *p = (char *) malloc (len); + char *p = (char *) hb_malloc (len); if (unlikely (!p)) return hb_bytes_t (); memcpy (p, this->start, this->head - this->start); @@ -566,7 +566,7 @@ struct hb_serialize_context_t hb_bytes_t b = copy_bytes (); return hb_blob_create (b.arrayZ, b.length, HB_MEMORY_MODE_WRITABLE, - (char *) b.arrayZ, free); + (char *) b.arrayZ, hb_free); } const hb_vector_t& object_graph() const diff --git a/src/hb-set.cc b/src/hb-set.cc index 5a3096dca..4a9b3e15b 100644 --- a/src/hb-set.cc +++ b/src/hb-set.cc @@ -109,7 +109,7 @@ hb_set_destroy (hb_set_t *set) set->fini_shallow (); - free (set); + hb_free (set); } /** diff --git a/src/hb-shape-plan.cc b/src/hb-shape-plan.cc index 56f3a2f75..aa7da2db3 100644 --- a/src/hb-shape-plan.cc +++ b/src/hb-shape-plan.cc @@ -66,7 +66,7 @@ hb_shape_plan_key_t::init (bool copy, const char * const *shaper_list) { hb_feature_t *features = nullptr; - if (copy && num_user_features && !(features = (hb_feature_t *) calloc (num_user_features, sizeof (hb_feature_t)))) + if (copy && num_user_features && !(features = (hb_feature_t *) hb_calloc (num_user_features, sizeof (hb_feature_t)))) goto bail; this->props = *props; @@ -130,7 +130,7 @@ hb_shape_plan_key_t::init (bool copy, #undef HB_SHAPER_PLAN bail: - ::free (features); + ::hb_free (features); return false; } @@ -266,7 +266,7 @@ bail3: #endif shape_plan->key.fini (); bail2: - free (shape_plan); + hb_free (shape_plan); bail: return hb_shape_plan_get_empty (); } @@ -321,7 +321,7 @@ hb_shape_plan_destroy (hb_shape_plan_t *shape_plan) shape_plan->ot.fini (); #endif shape_plan->key.fini (); - free (shape_plan); + hb_free (shape_plan); } /** @@ -560,7 +560,7 @@ retry: if (unlikely (dont_cache)) return shape_plan; - hb_face_t::plan_node_t *node = (hb_face_t::plan_node_t *) calloc (1, sizeof (hb_face_t::plan_node_t)); + hb_face_t::plan_node_t *node = (hb_face_t::plan_node_t *) hb_calloc (1, sizeof (hb_face_t::plan_node_t)); if (unlikely (!node)) return shape_plan; @@ -570,7 +570,7 @@ retry: if (unlikely (!face->shape_plans.cmpexch (cached_plan_nodes, node))) { hb_shape_plan_destroy (shape_plan); - free (node); + hb_free (node); goto retry; } DEBUG_MSG_FUNC (SHAPE_PLAN, shape_plan, "inserted into cache"); diff --git a/src/hb-shape-plan.hh b/src/hb-shape-plan.hh index e4779bef8..8cb4ddb92 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 fini () { free ((void *) user_features); } + HB_INTERNAL void fini () { hb_free ((void *) user_features); } HB_INTERNAL bool user_features_match (const hb_shape_plan_key_t *other); diff --git a/src/hb-shape.cc b/src/hb-shape.cc index c442f4403..f303a569f 100644 --- a/src/hb-shape.cc +++ b/src/hb-shape.cc @@ -59,7 +59,7 @@ static struct hb_shaper_list_lazy_loader_t : hb_lazy_loader_tdrop_tables); hb_set_destroy (subset_input->layout_features); - free (subset_input); + hb_free (subset_input); } /** diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 195378d0e..ba26979b8 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -107,7 +107,7 @@ static void _collect_subset_layout (hb_face_t *face, if (hb_set_is_empty (layout_features_to_retain)) return; unsigned num = layout_features_to_retain->get_population () + 1; - hb_tag_t *features = (hb_tag_t *) malloc (num * sizeof (hb_tag_t)); + hb_tag_t *features = (hb_tag_t *) hb_malloc (num * sizeof (hb_tag_t)); if (!features) return; unsigned i = 0; @@ -123,7 +123,7 @@ static void _collect_subset_layout (hb_face_t *face, features, lookup_indices); - free (features); + hb_free (features); } template @@ -495,7 +495,7 @@ hb_subset_plan_destroy (hb_subset_plan_t *plan) hb_object_destroy (plan->gsub_langsys); plan->gsub_langsys->fini_shallow (); - free (plan->gsub_langsys); + hb_free (plan->gsub_langsys); } if (plan->gpos_langsys) @@ -505,8 +505,8 @@ hb_subset_plan_destroy (hb_subset_plan_t *plan) hb_object_destroy (plan->gpos_langsys); plan->gpos_langsys->fini_shallow (); - free (plan->gpos_langsys); + hb_free (plan->gpos_langsys); } - free (plan); + hb_free (plan); } diff --git a/src/hb-unicode.cc b/src/hb-unicode.cc index 7470bb1b6..83ead6398 100644 --- a/src/hb-unicode.cc +++ b/src/hb-unicode.cc @@ -268,7 +268,7 @@ hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs) hb_unicode_funcs_destroy (ufuncs->parent); - free (ufuncs); + hb_free (ufuncs); } /** diff --git a/src/hb-uniscribe.cc b/src/hb-uniscribe.cc index 48a5dc50a..a9bed1b8e 100644 --- a/src/hb-uniscribe.cc +++ b/src/hb-uniscribe.cc @@ -247,7 +247,7 @@ static struct hb_uniscribe_shaper_funcs_lazy_loader_t : hb_lazy_loader_tfuncs = hb_uniscribe_shaper_get_funcs (); if (unlikely (!data->funcs)) { - free (data); + hb_free (data); return nullptr; } @@ -477,7 +477,7 @@ _hb_uniscribe_shaper_face_data_create (hb_face_t *face) blob = _hb_rename_font (blob, data->face_name); if (unlikely (!blob)) { - free (data); + hb_free (data); return nullptr; } @@ -488,7 +488,7 @@ _hb_uniscribe_shaper_face_data_create (hb_face_t *face) if (unlikely (!data->fh)) { DEBUG_MSG (UNISCRIBE, face, "Face AddFontMemResourceEx() failed"); - free (data); + hb_free (data); return nullptr; } @@ -499,7 +499,7 @@ void _hb_uniscribe_shaper_face_data_destroy (hb_uniscribe_face_data_t *data) { RemoveFontMemResourceEx (data->fh); - free (data); + hb_free (data); } @@ -533,7 +533,7 @@ populate_log_font (LOGFONTW *lf, hb_uniscribe_font_data_t * _hb_uniscribe_shaper_font_data_create (hb_font_t *font) { - hb_uniscribe_font_data_t *data = (hb_uniscribe_font_data_t *) calloc (1, sizeof (hb_uniscribe_font_data_t)); + hb_uniscribe_font_data_t *data = (hb_uniscribe_font_data_t *) hb_calloc (1, sizeof (hb_uniscribe_font_data_t)); if (unlikely (!data)) return nullptr; @@ -580,7 +580,7 @@ _hb_uniscribe_shaper_font_data_destroy (hb_uniscribe_font_data_t *data) DeleteObject (data->hfont); if (data->script_cache) ScriptFreeCache (&data->script_cache); - free (data); + hb_free (data); } /** diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 17f7d486f..9f55fd378 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -69,7 +69,7 @@ struct hb_vector_t void fini () { - free (arrayZ); + hb_free (arrayZ); init (); } void fini_deep () @@ -209,7 +209,7 @@ struct hb_vector_t (new_allocated < (unsigned) allocated) || hb_unsigned_mul_overflows (new_allocated, sizeof (Type)); if (likely (!overflows)) - new_array = (Type *) realloc (arrayZ, new_allocated * sizeof (Type)); + new_array = (Type *) hb_realloc (arrayZ, new_allocated * sizeof (Type)); if (unlikely (!new_array)) { diff --git a/src/hb.hh b/src/hb.hh index 4d90e4d57..558fea495 100644 --- a/src/hb.hh +++ b/src/hb.hh @@ -223,10 +223,15 @@ extern "C" void* hb_malloc_impl(size_t size); extern "C" void* hb_calloc_impl(size_t nmemb, size_t size); extern "C" void* hb_realloc_impl(void *ptr, size_t size); extern "C" void hb_free_impl(void *ptr); -#define malloc hb_malloc_impl -#define calloc hb_calloc_impl -#define realloc hb_realloc_impl -#define free hb_free_impl +#define hb_malloc hb_malloc_impl +#define hb_calloc hb_calloc_impl +#define hb_realloc hb_realloc_impl +#define hb_free hb_free_impl +#else +#define hb_malloc malloc +#define hb_calloc calloc +#define hb_realloc realloc +#define hb_free free #endif