Minor, add a zero length tolerant memset, hb_memset
diff --git a/src/hb-algs.hh b/src/hb-algs.hh
index c57481b..042e1c2 100644
--- a/src/hb-algs.hh
+++ b/src/hb-algs.hh
@@ -588,10 +588,18 @@
/* It's illegal to pass NULL to memcmp(), even if len is zero.
* So, wrap it.
* https://sourceware.org/bugzilla/show_bug.cgi?id=23878 */
- if (!len) return 0;
+ if (unlikely (!len)) return 0;
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
hb_unsigned_mul_overflows (unsigned int count, unsigned int size)
{
diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc
index bb7f3c7..40ac55c 100644
--- a/src/hb-buffer.cc
+++ b/src/hb-buffer.cc
@@ -324,8 +324,7 @@
out_len = 0;
out_info = info;
- if (likely (len))
- memset (pos, 0, sizeof (pos[0]) * len);
+ hb_memset (pos, 0, sizeof (pos[0]) * len);
}
void