[vector] Remove static_array
Was good idea, but with C++ types with constructor/destructor, was getting in the way as compiler was destructing those items where it was not desired. Since C++ does not allow zero-sized arrays, just remove it...
This commit is contained in:
parent
ab2258a419
commit
fa333e34d6
|
@ -44,7 +44,7 @@ struct hb_aat_map_t
|
||||||
void fini () { chain_flags.fini (); }
|
void fini () { chain_flags.fini (); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
hb_vector_t<hb_mask_t, 1> chain_flags;
|
hb_vector_t<hb_mask_t> chain_flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hb_aat_map_builder_t
|
struct hb_aat_map_builder_t
|
||||||
|
@ -84,7 +84,7 @@ struct hb_aat_map_builder_t
|
||||||
hb_face_t *face;
|
hb_face_t *face;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
hb_vector_t<feature_info_t, 32> features;
|
hb_vector_t<feature_info_t> features;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -482,7 +482,7 @@ struct stack_t
|
||||||
protected:
|
protected:
|
||||||
bool error;
|
bool error;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
hb_vector_t<ELEM, kSizeLimit> elements;
|
hb_vector_t<ELEM> elements;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* argument stack */
|
/* argument stack */
|
||||||
|
|
|
@ -599,7 +599,7 @@ struct hb_face_builder_data_t
|
||||||
hb_blob_t *blob;
|
hb_blob_t *blob;
|
||||||
};
|
};
|
||||||
|
|
||||||
hb_vector_t<table_entry_t, 32> tables;
|
hb_vector_t<table_entry_t> tables;
|
||||||
};
|
};
|
||||||
|
|
||||||
static hb_face_builder_data_t *
|
static hb_face_builder_data_t *
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
template <typename item_t, typename lock_t>
|
template <typename item_t, typename lock_t>
|
||||||
struct hb_lockable_set_t
|
struct hb_lockable_set_t
|
||||||
{
|
{
|
||||||
hb_vector_t <item_t, 1> items;
|
hb_vector_t<item_t> items;
|
||||||
|
|
||||||
void init () { items.init (); }
|
void init () { items.init (); }
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ struct code_pair_t
|
||||||
hb_codepoint_t glyph;
|
hb_codepoint_t glyph;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef hb_vector_t<unsigned char, 1> str_buff_t;
|
typedef hb_vector_t<unsigned char> str_buff_t;
|
||||||
struct str_buff_vec_t : hb_vector_t<str_buff_t>
|
struct str_buff_vec_t : hb_vector_t<str_buff_t>
|
||||||
{
|
{
|
||||||
void fini () { SUPER::fini_deep (); }
|
void fini () { SUPER::fini_deep (); }
|
||||||
|
|
|
@ -643,7 +643,7 @@ struct hb_get_subtables_context_t :
|
||||||
hb_set_digest_t digest;
|
hb_set_digest_t digest;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef hb_vector_t<hb_applicable_t, 2> array_t;
|
typedef hb_vector_t<hb_applicable_t> array_t;
|
||||||
|
|
||||||
/* Dispatch interface. */
|
/* Dispatch interface. */
|
||||||
const char *get_name () { return "GET_SUBTABLES"; }
|
const char *get_name () { return "GET_SUBTABLES"; }
|
||||||
|
|
|
@ -167,9 +167,9 @@ struct hb_ot_map_t
|
||||||
|
|
||||||
hb_mask_t global_mask;
|
hb_mask_t global_mask;
|
||||||
|
|
||||||
hb_vector_t<feature_map_t, 8> features;
|
hb_vector_t<feature_map_t> features;
|
||||||
hb_vector_t<lookup_map_t, 16> lookups[2]; /* GSUB/GPOS */
|
hb_vector_t<lookup_map_t> lookups[2]; /* GSUB/GPOS */
|
||||||
hb_vector_t<stage_map_t, 4> stages[2]; /* GSUB/GPOS */
|
hb_vector_t<stage_map_t> stages[2]; /* GSUB/GPOS */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum hb_ot_map_feature_flags_t
|
enum hb_ot_map_feature_flags_t
|
||||||
|
@ -275,8 +275,8 @@ struct hb_ot_map_builder_t
|
||||||
private:
|
private:
|
||||||
|
|
||||||
unsigned int current_stage[2]; /* GSUB/GPOS */
|
unsigned int current_stage[2]; /* GSUB/GPOS */
|
||||||
hb_vector_t<feature_info_t, 32> feature_infos;
|
hb_vector_t<feature_info_t> feature_infos;
|
||||||
hb_vector_t<stage_info_t, 8> stages[2]; /* GSUB/GPOS */
|
hb_vector_t<stage_info_t> stages[2]; /* GSUB/GPOS */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -241,7 +241,7 @@ struct post
|
||||||
hb_blob_ptr_t<post> table;
|
hb_blob_ptr_t<post> table;
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
const ArrayOf<HBUINT16> *glyphNameIndex;
|
const ArrayOf<HBUINT16> *glyphNameIndex;
|
||||||
hb_vector_t<uint32_t, 1> index_to_offset;
|
hb_vector_t<uint32_t> index_to_offset;
|
||||||
const uint8_t *pool;
|
const uint8_t *pool;
|
||||||
hb_atomic_ptr_t<uint16_t *> gids_sorted_by_name;
|
hb_atomic_ptr_t<uint16_t *> gids_sorted_by_name;
|
||||||
};
|
};
|
||||||
|
|
|
@ -186,8 +186,8 @@ struct hb_set_t
|
||||||
hb_object_header_t header;
|
hb_object_header_t header;
|
||||||
bool successful; /* Allocations successful */
|
bool successful; /* Allocations successful */
|
||||||
mutable unsigned int population;
|
mutable unsigned int population;
|
||||||
hb_vector_t<page_map_t, 1> page_map;
|
hb_vector_t<page_map_t> page_map;
|
||||||
hb_vector_t<page_t, 1> pages;
|
hb_vector_t<page_t> pages;
|
||||||
|
|
||||||
void init_shallow ()
|
void init_shallow ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,13 +32,13 @@
|
||||||
#include "hb-null.hh"
|
#include "hb-null.hh"
|
||||||
|
|
||||||
|
|
||||||
template <typename Type, unsigned int PreallocedCount=2>
|
template <typename Type>
|
||||||
struct hb_vector_t
|
struct hb_vector_t
|
||||||
{
|
{
|
||||||
typedef Type item_t;
|
typedef Type item_t;
|
||||||
enum { item_size = hb_static_size (Type) };
|
enum { item_size = hb_static_size (Type) };
|
||||||
|
|
||||||
HB_NO_COPY_ASSIGN_TEMPLATE2 (hb_vector_t, Type, PreallocedCount);
|
HB_NO_COPY_ASSIGN_TEMPLATE (hb_vector_t, Type);
|
||||||
hb_vector_t () { init (); }
|
hb_vector_t () { init (); }
|
||||||
~hb_vector_t () { fini (); }
|
~hb_vector_t () { fini (); }
|
||||||
|
|
||||||
|
@ -46,13 +46,11 @@ struct hb_vector_t
|
||||||
private:
|
private:
|
||||||
int allocated; /* == -1 means allocation failed. */
|
int allocated; /* == -1 means allocation failed. */
|
||||||
Type *arrayZ_;
|
Type *arrayZ_;
|
||||||
Type static_array[PreallocedCount];
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void init ()
|
void init ()
|
||||||
{
|
{
|
||||||
length = 0;
|
allocated = length = 0;
|
||||||
allocated = ARRAY_LENGTH (static_array);
|
|
||||||
arrayZ_ = nullptr;
|
arrayZ_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,8 +69,8 @@ struct hb_vector_t
|
||||||
fini ();
|
fini ();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Type * arrayZ () const { return arrayZ_ ? arrayZ_ : static_array; }
|
const Type * arrayZ () const { return arrayZ_; }
|
||||||
Type * arrayZ () { return arrayZ_ ? arrayZ_ : static_array; }
|
Type * arrayZ () { return arrayZ_; }
|
||||||
|
|
||||||
Type& operator [] (int i_)
|
Type& operator [] (int i_)
|
||||||
{
|
{
|
||||||
|
@ -158,22 +156,12 @@ struct hb_vector_t
|
||||||
new_allocated += (new_allocated >> 1) + 8;
|
new_allocated += (new_allocated >> 1) + 8;
|
||||||
|
|
||||||
Type *new_array = nullptr;
|
Type *new_array = nullptr;
|
||||||
|
|
||||||
if (!arrayZ_)
|
|
||||||
{
|
|
||||||
new_array = (Type *) calloc (new_allocated, sizeof (Type));
|
|
||||||
if (new_array)
|
|
||||||
memcpy (new_array, static_array, length * sizeof (Type));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bool overflows =
|
bool overflows =
|
||||||
(int) new_allocated < 0 ||
|
(int) new_allocated < 0 ||
|
||||||
(new_allocated < allocated) ||
|
(new_allocated < allocated) ||
|
||||||
hb_unsigned_mul_overflows (new_allocated, sizeof (Type));
|
hb_unsigned_mul_overflows (new_allocated, sizeof (Type));
|
||||||
if (likely (!overflows))
|
if (likely (!overflows))
|
||||||
new_array = (Type *) realloc (arrayZ_, new_allocated * sizeof (Type));
|
new_array = (Type *) realloc (arrayZ_, new_allocated * sizeof (Type));
|
||||||
}
|
|
||||||
|
|
||||||
if (unlikely (!new_array))
|
if (unlikely (!new_array))
|
||||||
{
|
{
|
||||||
|
|
|
@ -377,6 +377,9 @@ static_assert ((sizeof (hb_var_int_t) == 4), "");
|
||||||
#define HB_NO_COPY_ASSIGN(TypeName) \
|
#define HB_NO_COPY_ASSIGN(TypeName) \
|
||||||
TypeName(const TypeName&); \
|
TypeName(const TypeName&); \
|
||||||
void operator=(const TypeName&)
|
void operator=(const TypeName&)
|
||||||
|
#define HB_NO_COPY_ASSIGN_TEMPLATE(TypeName, T) \
|
||||||
|
TypeName(const TypeName<T>&); \
|
||||||
|
void operator=(const TypeName<T>&)
|
||||||
#define HB_NO_COPY_ASSIGN_TEMPLATE2(TypeName, T1, T2) \
|
#define HB_NO_COPY_ASSIGN_TEMPLATE2(TypeName, T1, T2) \
|
||||||
TypeName(const TypeName<T1, T2>&); \
|
TypeName(const TypeName<T1, T2>&); \
|
||||||
void operator=(const TypeName<T1, T2>&)
|
void operator=(const TypeName<T1, T2>&)
|
||||||
|
|
Loading…
Reference in New Issue