Internally use hb_malloc/.../hb_free instead of malloc/.../free

Redefining those stock names as macros was conflicting with gcc 10
headers.

Fixes https://github.com/harfbuzz/harfbuzz/issues/3044
This commit is contained in:
Behdad Esfahbod 2021-07-08 10:58:50 -06:00
parent bb48bf52a4
commit 2337f0d047
42 changed files with 179 additions and 174 deletions

View File

@ -231,9 +231,9 @@ struct hb_array_t : hb_iter_with_fallback_t<hb_array_t<Type>, 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 <typename hb_serialize_context_t>
hb_array_t copy (hb_serialize_context_t *c) const

View File

@ -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 */

View File

@ -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);
}
/**

View File

@ -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;
}

View File

@ -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;

View File

@ -191,7 +191,7 @@ hb_draw_funcs_destroy (hb_draw_funcs_t *funcs)
{
if (!hb_object_destroy (funcs)) return;
free (funcs);
hb_free (funcs);
}
/**

View File

@ -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 *

View File

@ -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<FuncType> 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_func_t> hb_font_get_glyph_trampoline_t;

View File

@ -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

View File

@ -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:

View File

@ -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)

View File

@ -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);
}
/**

View File

@ -242,14 +242,14 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData>
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<Data, WheresData>
static void destroy (Stored *p)
{
p->fini ();
free (p);
hb_free (p);
}
// private:

View File

@ -109,7 +109,7 @@ hb_map_destroy (hb_map_t *map)
map->fini_shallow ();
free (map);
hb_free (map);
}
/**

View File

@ -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;
}

View File

@ -217,7 +217,7 @@ static inline void hb_object_trace (const Type *obj, const char *function)
template <typename Type>
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;
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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 ();
}

View File

@ -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<NameRecord> 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);

View File

@ -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;
}
}

View File

@ -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<arabic_fallback_plan_t *> (&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<arabic_fallback_plan_t *> (&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

View File

@ -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

View File

@ -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. */

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);
}
}
}

View File

@ -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 ();

View File

@ -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;
}
};

View File

@ -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_t *>& object_graph() const

View File

@ -109,7 +109,7 @@ hb_set_destroy (hb_set_t *set)
set->fini_shallow ();
free (set);
hb_free (set);
}
/**

View File

@ -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");

View File

@ -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);

View File

@ -59,7 +59,7 @@ static struct hb_shaper_list_lazy_loader_t : hb_lazy_loader_t<const char *,
{
static const char ** create ()
{
const char **shaper_list = (const char **) calloc (1 + HB_SHAPERS_COUNT, sizeof (const char *));
const char **shaper_list = (const char **) hb_calloc (1 + HB_SHAPERS_COUNT, sizeof (const char *));
if (unlikely (!shaper_list))
return nullptr;
@ -76,7 +76,7 @@ static struct hb_shaper_list_lazy_loader_t : hb_lazy_loader_t<const char *,
return shaper_list;
}
static void destroy (const char **l)
{ free (l); }
{ hb_free (l); }
static const char ** get_null ()
{ return nil_shaper_list; }
} static_shaper_list;

View File

@ -51,7 +51,7 @@ static struct hb_shapers_lazy_loader_t : hb_lazy_loader_t<const hb_shaper_entry_
if (!env || !*env)
return nullptr;
hb_shaper_entry_t *shapers = (hb_shaper_entry_t *) calloc (1, sizeof (all_shapers));
hb_shaper_entry_t *shapers = (hb_shaper_entry_t *) hb_calloc (1, sizeof (all_shapers));
if (unlikely (!shapers))
return nullptr;
@ -89,7 +89,7 @@ static struct hb_shapers_lazy_loader_t : hb_lazy_loader_t<const hb_shaper_entry_
return shapers;
}
static void destroy (const hb_shaper_entry_t *p) { free ((void *) p); }
static void destroy (const hb_shaper_entry_t *p) { hb_free ((void *) p); }
static const hb_shaper_entry_t *get_null () { return all_shapers; }
} static_shapers;

View File

@ -211,7 +211,7 @@ hb_subset_input_destroy (hb_subset_input_t *subset_input)
hb_set_destroy (subset_input->drop_tables);
hb_set_destroy (subset_input->layout_features);
free (subset_input);
hb_free (subset_input);
}
/**

View File

@ -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 <typename T>
@ -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);
}

View File

@ -268,7 +268,7 @@ hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs)
hb_unicode_funcs_destroy (ufuncs->parent);
free (ufuncs);
hb_free (ufuncs);
}
/**

View File

@ -247,7 +247,7 @@ static struct hb_uniscribe_shaper_funcs_lazy_loader_t : hb_lazy_loader_t<hb_unis
{
static hb_uniscribe_shaper_funcs_t *create ()
{
hb_uniscribe_shaper_funcs_t *funcs = (hb_uniscribe_shaper_funcs_t *) calloc (1, sizeof (hb_uniscribe_shaper_funcs_t));
hb_uniscribe_shaper_funcs_t *funcs = (hb_uniscribe_shaper_funcs_t *) hb_calloc (1, sizeof (hb_uniscribe_shaper_funcs_t));
if (unlikely (!funcs))
return nullptr;
@ -261,7 +261,7 @@ static struct hb_uniscribe_shaper_funcs_lazy_loader_t : hb_lazy_loader_t<hb_unis
}
static void destroy (hb_uniscribe_shaper_funcs_t *p)
{
free ((void *) p);
hb_free ((void *) p);
}
static hb_uniscribe_shaper_funcs_t *get_null ()
{
@ -391,7 +391,7 @@ _hb_rename_font (hb_blob_t *blob, wchar_t *new_name)
unsigned int name_table_offset = (length + 3) & ~3;
new_length = name_table_offset + padded_name_table_length;
void *new_sfnt_data = calloc (1, new_length);
void *new_sfnt_data = hb_calloc (1, new_length);
if (!new_sfnt_data)
{
hb_blob_destroy (blob);
@ -441,7 +441,7 @@ _hb_rename_font (hb_blob_t *blob, wchar_t *new_name)
}
else if (face_index == 0) /* Fail if first face doesn't have 'name' table. */
{
free (new_sfnt_data);
hb_free (new_sfnt_data);
hb_blob_destroy (blob);
return nullptr;
}
@ -453,20 +453,20 @@ _hb_rename_font (hb_blob_t *blob, wchar_t *new_name)
hb_blob_destroy (blob);
return hb_blob_create ((const char *) new_sfnt_data, new_length,
HB_MEMORY_MODE_WRITABLE, new_sfnt_data, free);
HB_MEMORY_MODE_WRITABLE, new_sfnt_data, hb_free);
}
hb_uniscribe_face_data_t *
_hb_uniscribe_shaper_face_data_create (hb_face_t *face)
{
hb_uniscribe_face_data_t *data = (hb_uniscribe_face_data_t *) calloc (1, sizeof (hb_uniscribe_face_data_t));
hb_uniscribe_face_data_t *data = (hb_uniscribe_face_data_t *) hb_calloc (1, sizeof (hb_uniscribe_face_data_t));
if (unlikely (!data))
return nullptr;
data->funcs = 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);
}
/**

View File

@ -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))
{

View File

@ -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