Minor, add a zero length tolerant memset, hb_memset
This commit is contained in:
parent
e17e744300
commit
670fec231d
|
@ -588,10 +588,18 @@ hb_memcmp (const void *a, const void *b, unsigned int len)
|
||||||
/* It's illegal to pass NULL to memcmp(), even if len is zero.
|
/* It's illegal to pass NULL to memcmp(), even if len is zero.
|
||||||
* So, wrap it.
|
* So, wrap it.
|
||||||
* https://sourceware.org/bugzilla/show_bug.cgi?id=23878 */
|
* https://sourceware.org/bugzilla/show_bug.cgi?id=23878 */
|
||||||
if (!len) return 0;
|
if (unlikely (!len)) return 0;
|
||||||
return memcmp (a, b, len);
|
return memcmp (a, b, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void *
|
||||||
|
hb_memset (void *s, int c, unsigned int n)
|
||||||
|
{
|
||||||
|
/* It's illegal to pass NULL to memset(), even if n is zero. */
|
||||||
|
if (unlikely (!n)) return 0;
|
||||||
|
return memset (s, c, n);
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
hb_unsigned_mul_overflows (unsigned int count, unsigned int size)
|
hb_unsigned_mul_overflows (unsigned int count, unsigned int size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -324,8 +324,7 @@ hb_buffer_t::clear_positions ()
|
||||||
out_len = 0;
|
out_len = 0;
|
||||||
out_info = info;
|
out_info = info;
|
||||||
|
|
||||||
if (likely (len))
|
hb_memset (pos, 0, sizeof (pos[0]) * len);
|
||||||
memset (pos, 0, sizeof (pos[0]) * len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue