Codechange: use "[[maybe_unused]]" instead of a wide variety of other ways we had
While at it, replace OTTD_ASSERT with WITH_ASSERT, as this is always set if assert() is valid. No matter if NDEBUG is set or not.
This commit is contained in:
committed by
Patric Stout
parent
f8dd5dd00a
commit
28e90769f7
@@ -33,9 +33,9 @@ DEFINE_POOL_METHOD(inline)::Pool(const char *name) :
|
||||
first_free(0),
|
||||
first_unused(0),
|
||||
items(0),
|
||||
#ifdef OTTD_ASSERT
|
||||
#ifdef WITH_ASSERT
|
||||
checked(0),
|
||||
#endif /* OTTD_ASSERT */
|
||||
#endif /* WITH_ASSERT */
|
||||
cleaning(false),
|
||||
data(nullptr),
|
||||
alloc_cache(nullptr)
|
||||
@@ -133,10 +133,10 @@ DEFINE_POOL_METHOD(void *)::GetNew(size_t size)
|
||||
{
|
||||
size_t index = this->FindFirstFree();
|
||||
|
||||
#ifdef OTTD_ASSERT
|
||||
#ifdef WITH_ASSERT
|
||||
assert(this->checked != 0);
|
||||
this->checked--;
|
||||
#endif /* OTTD_ASSERT */
|
||||
#endif /* WITH_ASSERT */
|
||||
if (index == NO_FREE_ITEM) {
|
||||
error("%s: no more free items", this->name);
|
||||
}
|
||||
|
||||
@@ -90,9 +90,9 @@ struct Pool : PoolBase {
|
||||
size_t first_free; ///< No item with index lower than this is free (doesn't say anything about this one!)
|
||||
size_t first_unused; ///< This and all higher indexes are free (doesn't say anything about first_unused-1 !)
|
||||
size_t items; ///< Number of used indexes (non-nullptr)
|
||||
#ifdef OTTD_ASSERT
|
||||
#ifdef WITH_ASSERT
|
||||
size_t checked; ///< Number of items we checked for
|
||||
#endif /* OTTD_ASSERT */
|
||||
#endif /* WITH_ASSERT */
|
||||
bool cleaning; ///< True if cleaning pool (deleting all items)
|
||||
|
||||
Titem **data; ///< Pointer to array of pointers to Titem
|
||||
@@ -130,9 +130,9 @@ struct Pool : PoolBase {
|
||||
inline bool CanAllocate(size_t n = 1)
|
||||
{
|
||||
bool ret = this->items <= Tmax_size - n;
|
||||
#ifdef OTTD_ASSERT
|
||||
#ifdef WITH_ASSERT
|
||||
this->checked = ret ? n : 0;
|
||||
#endif /* OTTD_ASSERT */
|
||||
#endif /* WITH_ASSERT */
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user