Fix bug in text measurement cache

This commit is contained in:
Nic Barker 2024-09-02 11:06:14 +12:00
parent c248914292
commit 807fd62cd8
4 changed files with 17 additions and 15 deletions

View file

@ -0,0 +1,5 @@
void $NAME$_Add($NAME$ *array, $TYPE$ item) {
if (Clay__Array_IncrementCapacityCheck(array->length, array->capacity)) {
array->internalArray[array->length++] = item;
}
}

View file

@ -0,0 +1,3 @@
$TYPE$ $NAME$_Get($NAME$ *array, int index) {
return Clay__Array_RangeCheck(index, array->length) ? array->internalArray[index] : $DEFAULT_VALUE$;
}

View file

@ -3,7 +3,7 @@ void $NAME$_Set($NAME$ *array, int index, $TYPE$ value) {
array->internalArray[index] = value;
array->length = index < array->length ? array->length : index + 1;
} else {
Clay_StringArray_Add(&Clay_warnings, CLAY_STRING("Attempting to allocate array in arena, but arena is already at capacity and would overflow."));
Clay__StringArray_Add(&Clay_warnings, CLAY_STRING("Attempting to allocate array in arena, but arena is already at capacity and would overflow."));
#ifdef CLAY_OVERFLOW_TRAP
raise(SIGTRAP);
#endif