Fix for temporary storage overflow warning

Why do we need this?
* Now the user is not warned about temp memory overflow which may introduce hard to debug bugs with memory management.
Describe at least one specific and practical problem this solves for people developing a game
* The buffer overflown and the pointers have been overwritten - undefined behavior, the pc fly into space. This fix fixes what the warning is meant to be. Warn in overflow situation to avoid potential bugs.
Does this add complexity/friction for people making games? If so, how do you justify that?
* There's no complexity in this PR.
This commit is contained in:
kacpercwiklinski 2024-08-15 09:58:42 +02:00
parent c76d428a26
commit f9bf7ffee4

View file

@ -647,6 +647,7 @@ void* talloc(u64 size) {
if ((u8*)temporary_storage_pointer >= (u8*)temporary_storage+TEMPORARY_STORAGE_SIZE) {
if (!has_warned_temporary_storage_overflow) {
os_write_string_to_stdout(STR("WARNING: temporary storage was overflown, we wrap around at the start.\n"));
has_warned_temporary_storage_overflow = true;
}
temporary_storage_pointer = temporary_storage;
return talloc(size);;
@ -657,7 +658,7 @@ void* talloc(u64 size) {
void reset_temporary_storage() {
temporary_storage_pointer = temporary_storage;
has_warned_temporary_storage_overflow = true;
has_warned_temporary_storage_overflow = false;
}
#endif // NOT OOGABOOGA_LINK_EXTERNAL_INSTANCE