mirror of
https://github.com/nicbarker/clay.git
synced 2026-02-06 12:48:49 +00:00
Fix bug in text measurement cache
This commit is contained in:
parent
c248914292
commit
807fd62cd8
4 changed files with 17 additions and 15 deletions
5
generator/array_add_value.template.c
Normal file
5
generator/array_add_value.template.c
Normal 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;
|
||||
}
|
||||
}
|
||||
3
generator/array_get_value.template.c
Normal file
3
generator/array_get_value.template.c
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
$TYPE$ $NAME$_Get($NAME$ *array, int index) {
|
||||
return Clay__Array_RangeCheck(index, array->length) ? array->internalArray[index] : $DEFAULT_VALUE$;
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue