Add hb_memcpy() that does len=0 check

pull/3082/head
Behdad Esfahbod 3 years ago
parent 5f801da945
commit bf2c87bfe6
  1. 8
      src/hb-algs.hh
  2. 8
      src/hb-set.hh

@ -760,6 +760,14 @@ static inline unsigned int ARRAY_LENGTH (const Type (&)[n]) { return n; }
#define ARRAY_LENGTH_CONST(__array) ((signed int) (sizeof (__array) / sizeof (__array[0])))
static inline void *
hb_memcpy (void *__restrict dst, const void *__restrict src, size_t len)
{
/* It's illegal to pass 0 as size to memcpy. */
if (unlikely (!len)) return dst;
return memcpy (dst, src, len);
}
static inline int
hb_memcmp (const void *a, const void *b, unsigned int len)
{

@ -489,12 +489,8 @@ struct hb_set_t
return;
population = other.population;
if (!count)
// memcpy is not necessary if the vectors are zero length. This avoids possibly
// passing nullptr to memcpy.
return;
memcpy ((void *) pages, (const void *) other.pages, count * pages.item_size);
memcpy ((void *) page_map, (const void *) other.page_map, count * page_map.item_size);
hb_memcpy ((void *) pages, (const void *) other.pages, count * pages.item_size);
hb_memcpy ((void *) page_map, (const void *) other.page_map, count * page_map.item_size);
}
bool is_equal (const hb_set_t &other) const

Loading…
Cancel
Save