Update to 14.0-beta1

This commit is contained in:
dP
2024-02-04 02:18:17 +05:30
parent 79037e2c65
commit 33ef333b57
1325 changed files with 138465 additions and 70987 deletions

View File

@@ -13,6 +13,9 @@
#include "alloc_func.hpp"
#include "mem_func.hpp"
#include "pool_type.hpp"
#include "../error_func.h"
#include "../saveload/saveload_error.hpp" // SlErrorCorruptFmt
/**
* Helper for defining the method's signature.
@@ -127,7 +130,7 @@ DEFINE_POOL_METHOD(inline void *)::AllocateItem(size_t size, size_t index)
* Allocates new item
* @param size size of item
* @return pointer to allocated item
* @note error() on failure! (no free item)
* @note FatalError() on failure! (no free item)
*/
DEFINE_POOL_METHOD(void *)::GetNew(size_t size)
{
@@ -138,7 +141,7 @@ DEFINE_POOL_METHOD(void *)::GetNew(size_t size)
this->checked--;
#endif /* WITH_ASSERT */
if (index == NO_FREE_ITEM) {
error("%s: no more free items", this->name);
FatalError("{}: no more free items", this->name);
}
this->first_free = index + 1;
@@ -154,16 +157,14 @@ DEFINE_POOL_METHOD(void *)::GetNew(size_t size)
*/
DEFINE_POOL_METHOD(void *)::GetNew(size_t size, size_t index)
{
extern void NORETURN SlErrorCorruptFmt(const char *format, ...);
if (index >= Tmax_size) {
SlErrorCorruptFmt("%s index " PRINTF_SIZE " out of range (" PRINTF_SIZE ")", this->name, index, Tmax_size);
SlErrorCorruptFmt("{} index {} out of range ({})", this->name, index, Tmax_size);
}
if (index >= this->size) this->ResizeFor(index);
if (this->data[index] != nullptr) {
SlErrorCorruptFmt("%s index " PRINTF_SIZE " already in use", this->name, index);
SlErrorCorruptFmt("{} index {} already in use", this->name, index);
}
return this->AllocateItem(size, index);