Imported Upstream version 3.4.0
[platform/upstream/harfbuzz.git] / src / hb-machinery.hh
index 54bc60d..b529173 100644 (file)
@@ -80,6 +80,11 @@ static inline Type& StructAfter(TObject &X)
  * Size checking
  */
 
+/* Size signifying variable-sized array */
+#ifndef HB_VAR_ARRAY
+#define HB_VAR_ARRAY 1
+#endif
+
 /* Check _assertion in a method environment */
 #define _DEFINE_INSTANCE_ASSERTION1(_line, _assertion) \
   void _instance_assertion_on_line_##_line () const \
@@ -189,7 +194,8 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData>
   }
 
   const Returned * operator -> () const { return get (); }
-  const Returned & operator * () const  { return *get (); }
+  template <typename U = Returned, hb_enable_if (!hb_is_same (U, void))>
+  const U & operator * () const  { return *get (); }
   explicit operator bool () const
   { return get_stored () != Funcs::get_null (); }
   template <typename C> operator const C * () const { return get (); }
@@ -237,22 +243,22 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData>
   static const Stored* get_null () { return &Null (Stored); }
   static Stored *create (Data *data)
   {
-    Stored *p = (Stored *) calloc (1, sizeof (Stored));
+    Stored *p = (Stored *) hb_calloc (1, sizeof (Stored));
     if (likely (p))
-      p->init (data);
+      p = new (p) Stored (data);
     return p;
   }
   static Stored *create ()
   {
-    Stored *p = (Stored *) calloc (1, sizeof (Stored));
+    Stored *p = (Stored *) hb_calloc (1, sizeof (Stored));
     if (likely (p))
-      p->init ();
+      p = new (p) Stored ();
     return p;
   }
   static void destroy (Stored *p)
   {
-    p->fini ();
-    free (p);
+    p->~Stored ();
+    hb_free (p);
   }
 
 //  private: