[vector] Keep success status
This commit is contained in:
parent
1ab3c3ed1b
commit
975bdd5ef5
|
@ -625,11 +625,12 @@ struct CrapOrNull<const Type> {
|
||||||
|
|
||||||
|
|
||||||
#define HB_PREALLOCED_ARRAY_INIT {0, 0, nullptr}
|
#define HB_PREALLOCED_ARRAY_INIT {0, 0, nullptr}
|
||||||
template <typename Type, unsigned int StaticSize=16>
|
template <typename Type, unsigned int StaticSize=8>
|
||||||
struct hb_vector_t
|
struct hb_vector_t
|
||||||
{
|
{
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
unsigned int allocated;
|
unsigned int allocated;
|
||||||
|
bool successful;
|
||||||
Type *arrayZ;
|
Type *arrayZ;
|
||||||
Type static_array[StaticSize];
|
Type static_array[StaticSize];
|
||||||
|
|
||||||
|
@ -637,6 +638,7 @@ struct hb_vector_t
|
||||||
{
|
{
|
||||||
len = 0;
|
len = 0;
|
||||||
allocated = ARRAY_LENGTH (static_array);
|
allocated = ARRAY_LENGTH (static_array);
|
||||||
|
successful = true;
|
||||||
arrayZ = static_array;
|
arrayZ = static_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,6 +674,9 @@ struct hb_vector_t
|
||||||
/* Allocate for size but don't adjust len. */
|
/* Allocate for size but don't adjust len. */
|
||||||
inline bool alloc (unsigned int size)
|
inline bool alloc (unsigned int size)
|
||||||
{
|
{
|
||||||
|
if (unlikely (!successful))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (likely (size <= allocated))
|
if (likely (size <= allocated))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -697,7 +702,10 @@ struct hb_vector_t
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely (!new_array))
|
if (unlikely (!new_array))
|
||||||
|
{
|
||||||
|
successful = false;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
arrayZ = new_array;
|
arrayZ = new_array;
|
||||||
allocated = new_allocated;
|
allocated = new_allocated;
|
||||||
|
|
Loading…
Reference in New Issue