From: Behdad Esfahbod Date: Mon, 10 Sep 2018 23:07:06 +0000 (+0200) Subject: Add (unused) hb_array_t<> X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=13a8786c7c580651d8a6db9345b9aa85ca8ed956;p=platform%2Fupstream%2FlibHarfBuzzSharp.git Add (unused) hb_array_t<> --- diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index 7e06ff1..def968e 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -29,6 +29,8 @@ #include "hb.hh" +#include "hb-null.hh" + /* Void! For when we need a expression-type of void. */ typedef const struct _hb_void_t *hb_void_t; @@ -507,6 +509,24 @@ struct hb_auto_t : Type void fini (void) {} }; +template +struct hb_array_t +{ + inline hb_array_t (void) : arrayZ (nullptr), len (0) {} + inline hb_array_t (const T *array_, unsigned int len_) : arrayZ (array_), len (len_) {} + + inline const T& operator [] (unsigned int i) const + { + if (unlikely (i >= len)) return Null(T); + return arrayZ[i]; + } + + inline void free (void) { ::free ((void *) arrayZ); arrayZ = nullptr; len = 0; } + + const T *arrayZ; + unsigned int len; +}; + struct hb_bytes_t { inline hb_bytes_t (void) : bytes (nullptr), len (0) {}