Use hb_memcpy instead of memcpy consistently
This commit is contained in:
parent
ac0efaf818
commit
59c45f6deb
|
@ -131,14 +131,14 @@ struct RearrangementSubtable
|
|||
hb_glyph_info_t *info = buffer->info;
|
||||
hb_glyph_info_t buf[4];
|
||||
|
||||
memcpy (buf, info + start, l * sizeof (buf[0]));
|
||||
memcpy (buf + 2, info + end - r, r * sizeof (buf[0]));
|
||||
hb_memcpy (buf, info + start, l * sizeof (buf[0]));
|
||||
hb_memcpy (buf + 2, info + end - r, r * sizeof (buf[0]));
|
||||
|
||||
if (l != r)
|
||||
memmove (info + start + r, info + start + l, (end - start - l - r) * sizeof (buf[0]));
|
||||
|
||||
memcpy (info + start, buf + 2, r * sizeof (buf[0]));
|
||||
memcpy (info + end - l, buf, l * sizeof (buf[0]));
|
||||
hb_memcpy (info + start, buf + 2, r * sizeof (buf[0]));
|
||||
hb_memcpy (info + end - l, buf, l * sizeof (buf[0]));
|
||||
if (reverse_l)
|
||||
{
|
||||
buf[0] = info[end - 1];
|
||||
|
|
|
@ -495,7 +495,7 @@ hb_blob_t::try_make_writable ()
|
|||
|
||||
DEBUG_MSG_FUNC (BLOB, this, "dupped successfully -> %p\n", this->data);
|
||||
|
||||
memcpy (new_data, this->data, this->length);
|
||||
hb_memcpy (new_data, this->data, this->length);
|
||||
this->destroy_user_data ();
|
||||
this->mode = HB_MEMORY_MODE_WRITABLE;
|
||||
this->data = new_data;
|
||||
|
|
|
@ -183,7 +183,7 @@ _hb_buffer_serialize_glyphs_json (hb_buffer_t *buffer,
|
|||
unsigned int l = p - b;
|
||||
if (buf_size > l)
|
||||
{
|
||||
memcpy (buf, b, l);
|
||||
hb_memcpy (buf, b, l);
|
||||
buf += l;
|
||||
buf_size -= l;
|
||||
*buf_consumed += l;
|
||||
|
@ -241,7 +241,7 @@ _hb_buffer_serialize_unicode_json (hb_buffer_t *buffer,
|
|||
unsigned int l = p - b;
|
||||
if (buf_size > l)
|
||||
{
|
||||
memcpy (buf, b, l);
|
||||
hb_memcpy (buf, b, l);
|
||||
buf += l;
|
||||
buf_size -= l;
|
||||
*buf_consumed += l;
|
||||
|
@ -329,7 +329,7 @@ _hb_buffer_serialize_glyphs_text (hb_buffer_t *buffer,
|
|||
unsigned int l = p - b;
|
||||
if (buf_size > l)
|
||||
{
|
||||
memcpy (buf, b, l);
|
||||
hb_memcpy (buf, b, l);
|
||||
buf += l;
|
||||
buf_size -= l;
|
||||
*buf_consumed += l;
|
||||
|
@ -381,7 +381,7 @@ _hb_buffer_serialize_unicode_text (hb_buffer_t *buffer,
|
|||
unsigned int l = p - b;
|
||||
if (buf_size > l)
|
||||
{
|
||||
memcpy (buf, b, l);
|
||||
hb_memcpy (buf, b, l);
|
||||
buf += l;
|
||||
buf_size -= l;
|
||||
*buf_consumed += l;
|
||||
|
|
|
@ -209,7 +209,7 @@ hb_buffer_t::make_room_for (unsigned int num_in,
|
|||
assert (have_output);
|
||||
|
||||
out_info = (hb_glyph_info_t *) pos;
|
||||
memcpy (out_info, info, out_len * sizeof (out_info[0]));
|
||||
hb_memcpy (out_info, info, out_len * sizeof (out_info[0]));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1905,9 +1905,9 @@ hb_buffer_append (hb_buffer_t *buffer,
|
|||
|
||||
hb_segment_properties_overlay (&buffer->props, &source->props);
|
||||
|
||||
memcpy (buffer->info + orig_len, source->info + start, (end - start) * sizeof (buffer->info[0]));
|
||||
hb_memcpy (buffer->info + orig_len, source->info + start, (end - start) * sizeof (buffer->info[0]));
|
||||
if (buffer->have_positions)
|
||||
memcpy (buffer->pos + orig_len, source->pos + start, (end - start) * sizeof (buffer->pos[0]));
|
||||
hb_memcpy (buffer->pos + orig_len, source->pos + start, (end - start) * sizeof (buffer->pos[0]));
|
||||
|
||||
if (source->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE)
|
||||
{
|
||||
|
|
|
@ -501,7 +501,7 @@ struct op_serializer_t
|
|||
|
||||
unsigned char *d = c->allocate_size<unsigned char> (opstr.length);
|
||||
if (unlikely (!d)) return_trace (false);
|
||||
/* Faster than memcpy for small strings. */
|
||||
/* Faster than hb_memcpy for small strings. */
|
||||
for (unsigned i = 0; i < opstr.length; i++)
|
||||
d[i] = opstr.ptr[i];
|
||||
return_trace (true);
|
||||
|
|
|
@ -285,7 +285,7 @@ struct hb_language_item_t {
|
|||
lang = (hb_language_t) hb_malloc(len);
|
||||
if (likely (lang))
|
||||
{
|
||||
memcpy((unsigned char *) lang, s, len);
|
||||
hb_memcpy((unsigned char *) lang, s, len);
|
||||
for (unsigned char *p = (unsigned char *) lang; *p; p++)
|
||||
*p = canon_map[*p];
|
||||
}
|
||||
|
@ -379,7 +379,7 @@ hb_language_from_string (const char *str, int len)
|
|||
/* NUL-terminate it. */
|
||||
char strbuf[64];
|
||||
len = hb_min (len, (int) sizeof (strbuf) - 1);
|
||||
memcpy (strbuf, str, len);
|
||||
hb_memcpy (strbuf, str, len);
|
||||
strbuf[len] = '\0';
|
||||
item = lang_find_or_insert (strbuf);
|
||||
}
|
||||
|
@ -1025,7 +1025,7 @@ hb_feature_to_string (hb_feature_t *feature,
|
|||
}
|
||||
assert (len < ARRAY_LENGTH (s));
|
||||
len = hb_min (len, size - 1);
|
||||
memcpy (buf, s, len);
|
||||
hb_memcpy (buf, s, len);
|
||||
buf[len] = '\0';
|
||||
}
|
||||
|
||||
|
@ -1166,7 +1166,7 @@ hb_variation_to_string (hb_variation_t *variation,
|
|||
|
||||
assert (len < ARRAY_LENGTH (s));
|
||||
len = hb_min (len, size - 1);
|
||||
memcpy (buf, s, len);
|
||||
hb_memcpy (buf, s, len);
|
||||
buf[len] = '\0';
|
||||
}
|
||||
|
||||
|
|
|
@ -1803,8 +1803,8 @@ hb_font_create_sub_font (hb_font_t *parent)
|
|||
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]));
|
||||
memcpy (design_coords, parent->design_coords, num_coords * sizeof (parent->design_coords[0]));
|
||||
hb_memcpy (coords, parent->coords, num_coords * sizeof (parent->coords[0]));
|
||||
hb_memcpy (design_coords, parent->design_coords, num_coords * sizeof (parent->design_coords[0]));
|
||||
_hb_font_adopt_var_coords (font, coords, design_coords, num_coords);
|
||||
}
|
||||
else
|
||||
|
@ -2466,7 +2466,7 @@ hb_font_set_var_coords_design (hb_font_t *font,
|
|||
}
|
||||
|
||||
if (coords_length)
|
||||
memcpy (design_coords, coords, coords_length * sizeof (font->design_coords[0]));
|
||||
hb_memcpy (design_coords, coords, coords_length * sizeof (font->design_coords[0]));
|
||||
|
||||
hb_ot_var_normalize_coords (font->face, coords_length, coords, normalized);
|
||||
_hb_font_adopt_var_coords (font, normalized, design_coords, coords_length);
|
||||
|
@ -2542,8 +2542,8 @@ hb_font_set_var_coords_normalized (hb_font_t *font,
|
|||
|
||||
if (coords_length)
|
||||
{
|
||||
memcpy (copy, coords, coords_length * sizeof (coords[0]));
|
||||
memcpy (unmapped, coords, coords_length * sizeof (coords[0]));
|
||||
hb_memcpy (copy, coords, coords_length * sizeof (coords[0]));
|
||||
hb_memcpy (unmapped, coords, coords_length * sizeof (coords[0]));
|
||||
}
|
||||
|
||||
/* Best effort design coords simulation */
|
||||
|
|
|
@ -158,7 +158,7 @@ typedef struct OpenTypeOffsetTable
|
|||
return_trace (false);
|
||||
|
||||
if (likely (len))
|
||||
memcpy (start, blob->data, len);
|
||||
hb_memcpy (start, blob->data, len);
|
||||
|
||||
/* 4-byte alignment. */
|
||||
c->align (4);
|
||||
|
|
|
@ -68,7 +68,7 @@ struct CFFIndex
|
|||
unsigned int size = get_size ();
|
||||
CFFIndex *out = c->allocate_size<CFFIndex> (size);
|
||||
if (likely (out))
|
||||
memcpy (out, this, size);
|
||||
hb_memcpy (out, this, size);
|
||||
return_trace (out);
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ struct CFFIndex
|
|||
const hb_ubytes_t &bs = byteArray[i];
|
||||
unsigned char *dest = c->allocate_size<unsigned char> (bs.length);
|
||||
if (unlikely (!dest)) return_trace (false);
|
||||
memcpy (dest, &bs[0], bs.length);
|
||||
hb_memcpy (dest, &bs[0], bs.length);
|
||||
}
|
||||
|
||||
return_trace (true);
|
||||
|
@ -508,7 +508,7 @@ struct FDSelect
|
|||
unsigned int size = src.get_size (num_glyphs);
|
||||
FDSelect *dest = c->allocate_size<FDSelect> (size);
|
||||
if (unlikely (!dest)) return_trace (false);
|
||||
memcpy (dest, &src, size);
|
||||
hb_memcpy (dest, &src, size);
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ struct Encoding
|
|||
unsigned int size = src.get_size ();
|
||||
Encoding *dest = c->allocate_size<Encoding> (size);
|
||||
if (unlikely (!dest)) return_trace (false);
|
||||
memcpy (dest, &src, size);
|
||||
hb_memcpy (dest, &src, size);
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
|
@ -471,7 +471,7 @@ struct Charset
|
|||
unsigned int size = src.get_size (num_glyphs);
|
||||
Charset *dest = c->allocate_size<Charset> (size);
|
||||
if (unlikely (!dest)) return_trace (false);
|
||||
memcpy (dest, &src, size);
|
||||
hb_memcpy (dest, &src, size);
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ struct CFF2FDSelect
|
|||
unsigned int size = src.get_size (num_glyphs);
|
||||
CFF2FDSelect *dest = c->allocate_size<CFF2FDSelect> (size);
|
||||
if (unlikely (!dest)) return_trace (false);
|
||||
memcpy (dest, &src, size);
|
||||
hb_memcpy (dest, &src, size);
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ struct CFF2VariationStore
|
|||
unsigned int size_ = varStore->get_size ();
|
||||
CFF2VariationStore *dest = c->allocate_size<CFF2VariationStore> (size_);
|
||||
if (unlikely (!dest)) return_trace (false);
|
||||
memcpy (dest, varStore, size_);
|
||||
hb_memcpy (dest, varStore, size_);
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ _copy_data_to_cbdt (hb_vector_t<char> *cbdt_prime,
|
|||
{
|
||||
unsigned int new_len = cbdt_prime->length + length;
|
||||
if (unlikely (!cbdt_prime->alloc (new_len))) return false;
|
||||
memcpy (cbdt_prime->arrayZ + cbdt_prime->length, data, length);
|
||||
hb_memcpy (cbdt_prime->arrayZ + cbdt_prime->length, data, length);
|
||||
cbdt_prime->length = new_len;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2338,7 +2338,7 @@ struct VarRegionList
|
|||
{
|
||||
unsigned int backward = region_map.backward (r);
|
||||
if (backward >= region_count) return_trace (false);
|
||||
memcpy (&axesZ[axisCount * r], &src->axesZ[axisCount * backward], VarRegionAxis::static_size * axisCount);
|
||||
hb_memcpy (&axesZ[axisCount * r], &src->axesZ[axisCount * backward], VarRegionAxis::static_size * axisCount);
|
||||
}
|
||||
|
||||
return_trace (true);
|
||||
|
|
|
@ -77,11 +77,11 @@ struct MathConstants
|
|||
|
||||
HBINT16 *p = c->allocate_size<HBINT16> (HBINT16::static_size * 2);
|
||||
if (unlikely (!p)) return_trace (nullptr);
|
||||
memcpy (p, percentScaleDown, HBINT16::static_size * 2);
|
||||
hb_memcpy (p, percentScaleDown, HBINT16::static_size * 2);
|
||||
|
||||
HBUINT16 *m = c->allocate_size<HBUINT16> (HBUINT16::static_size * 2);
|
||||
if (unlikely (!m)) return_trace (nullptr);
|
||||
memcpy (m, minHeight, HBUINT16::static_size * 2);
|
||||
hb_memcpy (m, minHeight, HBUINT16::static_size * 2);
|
||||
|
||||
unsigned count = ARRAY_LENGTH (mathValueRecords);
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
|
|
|
@ -321,7 +321,7 @@ struct name
|
|||
|
||||
for (const NameRecord& record : it)
|
||||
{
|
||||
memcpy (name_records, &record, NameRecord::static_size);
|
||||
hb_memcpy (name_records, &record, NameRecord::static_size);
|
||||
name_records++;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ struct post
|
|||
post *post_prime = c->allocate_min<post> ();
|
||||
if (unlikely (!post_prime)) return_trace (false);
|
||||
|
||||
memcpy (post_prime, this, post::min_size);
|
||||
hb_memcpy (post_prime, this, post::min_size);
|
||||
if (!glyph_names)
|
||||
return_trace (c->check_assign (post_prime->version.major, 3,
|
||||
HB_SERIALIZE_ERROR_INT_OVERFLOW)); // Version 3 does not have any glyph names.
|
||||
|
|
|
@ -320,7 +320,7 @@ struct AxisValueFormat4
|
|||
unsigned total_size = min_size + axisCount * AxisValueRecord::static_size;
|
||||
auto *out = c->serializer->allocate_size<AxisValueFormat4> (total_size);
|
||||
if (unlikely (!out)) return_trace (false);
|
||||
memcpy (out, this, total_size);
|
||||
hb_memcpy (out, this, total_size);
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
|
|
|
@ -577,7 +577,7 @@ hb_ot_tags_to_script_and_language (hb_tag_t script_tag,
|
|||
else
|
||||
{
|
||||
int shift;
|
||||
memcpy (buf, lang_str, len);
|
||||
hb_memcpy (buf, lang_str, len);
|
||||
if (lang_str[0] != 'x' || lang_str[1] != '-') {
|
||||
buf[len++] = '-';
|
||||
buf[len++] = 'x';
|
||||
|
|
|
@ -47,7 +47,7 @@ struct DeltaSetIndexMapFormat01
|
|||
HBUINT8 *p = c->allocate_size<HBUINT8> (total_size);
|
||||
if (unlikely (!p)) return_trace (nullptr);
|
||||
|
||||
memcpy (p, this, HBUINT8::static_size * total_size);
|
||||
hb_memcpy (p, this, HBUINT8::static_size * total_size);
|
||||
return_trace (out);
|
||||
}
|
||||
|
||||
|
|
|
@ -454,7 +454,7 @@ struct gvar
|
|||
F2DOT14 *tuples = c->serializer->allocate_size<F2DOT14> (shared_tuple_size);
|
||||
if (!tuples) return_trace (false);
|
||||
out->sharedTuples = (char *) tuples - (char *) out;
|
||||
memcpy (tuples, this+sharedTuples, shared_tuple_size);
|
||||
hb_memcpy (tuples, this+sharedTuples, shared_tuple_size);
|
||||
}
|
||||
|
||||
char *subset_data = c->serializer->allocate_size<char> (subset_data_size);
|
||||
|
@ -477,7 +477,7 @@ struct gvar
|
|||
((HBUINT16 *) subset_offsets)[gid] = glyph_offset / 2;
|
||||
|
||||
if (var_data_bytes.length > 0)
|
||||
memcpy (subset_data, var_data_bytes.arrayZ, var_data_bytes.length);
|
||||
hb_memcpy (subset_data, var_data_bytes.arrayZ, var_data_bytes.length);
|
||||
subset_data += var_data_bytes.length;
|
||||
glyph_offset += var_data_bytes.length;
|
||||
}
|
||||
|
|
|
@ -596,7 +596,7 @@ struct hb_serialize_context_t
|
|||
unsigned int size = obj->get_size ();
|
||||
Type *ret = this->allocate_size<Type> (size);
|
||||
if (unlikely (!ret)) return nullptr;
|
||||
memcpy (ret, obj, size);
|
||||
hb_memcpy (ret, obj, size);
|
||||
return ret;
|
||||
}
|
||||
template <typename Type>
|
||||
|
@ -617,7 +617,7 @@ struct hb_serialize_context_t
|
|||
}
|
||||
|
||||
/* Like embed, but active: calls obj.operator=() or obj.copy() to transfer data
|
||||
* instead of memcpy(). */
|
||||
* instead of hb_memcpy(). */
|
||||
template <typename Type, typename ...Ts>
|
||||
Type *copy (const Type &src, Ts&&... ds)
|
||||
{ return _copy (src, hb_prioritize, std::forward<Ts> (ds)...); }
|
||||
|
@ -677,8 +677,8 @@ struct hb_serialize_context_t
|
|||
char *p = (char *) hb_malloc (len);
|
||||
if (unlikely (!p)) return hb_bytes_t ();
|
||||
|
||||
memcpy (p, this->start, this->head - this->start);
|
||||
memcpy (p + (this->head - this->start), this->tail, this->end - this->tail);
|
||||
hb_memcpy (p, this->start, this->head - this->start);
|
||||
hb_memcpy (p + (this->head - this->start), this->tail, this->end - this->tail);
|
||||
return hb_bytes_t (p, len);
|
||||
}
|
||||
template <typename Type>
|
||||
|
|
|
@ -74,7 +74,7 @@ hb_shape_plan_key_t::init (bool copy,
|
|||
this->user_features = copy ? features : user_features;
|
||||
if (copy && num_user_features)
|
||||
{
|
||||
memcpy (features, user_features, num_user_features * sizeof (hb_feature_t));
|
||||
hb_memcpy (features, user_features, num_user_features * sizeof (hb_feature_t));
|
||||
/* Make start/end uniform to easier catch bugs. */
|
||||
for (unsigned int i = 0; i < num_user_features; i++)
|
||||
{
|
||||
|
|
|
@ -53,7 +53,7 @@ static struct hb_shapers_lazy_loader_t : hb_lazy_loader_t<hb_shaper_entry_t,
|
|||
if (unlikely (!shapers))
|
||||
return nullptr;
|
||||
|
||||
memcpy (shapers, _hb_all_shapers, sizeof (_hb_all_shapers));
|
||||
hb_memcpy (shapers, _hb_all_shapers, sizeof (_hb_all_shapers));
|
||||
|
||||
/* Reorder shaper list to prefer requested shapers. */
|
||||
unsigned int i = 0;
|
||||
|
|
|
@ -113,7 +113,7 @@ struct str_encoder_t
|
|||
else if (unlikely (!buff.resize (offset + length)))
|
||||
return;
|
||||
|
||||
/* Faster than memcpy for small strings. */
|
||||
/* Faster than hb_memcpy for small strings. */
|
||||
for (unsigned i = 0; i < length; i++)
|
||||
buff.arrayZ[i + offset] = str[i];
|
||||
//hb_memcpy (buff.arrayZ + offset, str, length);
|
||||
|
@ -184,7 +184,7 @@ struct cff_font_dict_op_serializer_t : op_serializer_t
|
|||
{
|
||||
unsigned char *d = c->allocate_size<unsigned char> (opstr.length);
|
||||
if (unlikely (!d)) return_trace (false);
|
||||
/* Faster than memcpy for small strings. */
|
||||
/* Faster than hb_memcpy for small strings. */
|
||||
for (unsigned i = 0; i < opstr.length; i++)
|
||||
d[i] = opstr.ptr[i];
|
||||
//hb_memcpy (d, opstr.ptr, opstr.length);
|
||||
|
|
|
@ -355,7 +355,7 @@ _hb_rename_font (hb_blob_t *blob, wchar_t *new_name)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
memcpy(new_sfnt_data, orig_sfnt_data, length);
|
||||
hb_memcpy(new_sfnt_data, orig_sfnt_data, length);
|
||||
|
||||
OT::name &name = StructAtOffset<OT::name> (new_sfnt_data, name_table_offset);
|
||||
name.format = 0;
|
||||
|
@ -482,7 +482,7 @@ populate_log_font (LOGFONTW *lf,
|
|||
lf->lfHeight = - (int) font_size;
|
||||
lf->lfCharSet = DEFAULT_CHARSET;
|
||||
|
||||
memcpy (lf->lfFaceName, font->face->data.uniscribe->face_name, sizeof (lf->lfFaceName));
|
||||
hb_memcpy (lf->lfFaceName, font->face->data.uniscribe->face_name, sizeof (lf->lfFaceName));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ static void extend (const char* value,
|
|||
hb_serialize_context_t* c)
|
||||
{
|
||||
char* obj = c->allocate_size<char> (len);
|
||||
memcpy (obj, value, len);
|
||||
hb_memcpy (obj, value, len);
|
||||
}
|
||||
|
||||
static void start_object(const char* tag,
|
||||
|
|
Loading…
Reference in New Issue