mirror of https://github.com/OpenTTD/OpenTTD
(svn r22088) [1.1] -Revert (r22041): assertions to check whether Pools are actually checked before allocation still triggered in some corner cases, so leave it in trunk but remove it from the 1.1 branch
parent
5be6a1c7e6
commit
177135320d
|
@ -123,10 +123,6 @@ DEFINE_POOL_METHOD(void *)::GetNew(size_t size)
|
||||||
{
|
{
|
||||||
size_t index = this->FindFirstFree();
|
size_t index = this->FindFirstFree();
|
||||||
|
|
||||||
#ifdef OTTD_ASSERT
|
|
||||||
assert(this->checked != 0);
|
|
||||||
this->checked--;
|
|
||||||
#endif /* OTTD_ASSERT */
|
|
||||||
if (index == NO_FREE_ITEM) {
|
if (index == NO_FREE_ITEM) {
|
||||||
error("%s: no more free items", this->name);
|
error("%s: no more free items", this->name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,6 @@ struct Pool {
|
||||||
size_t first_free; ///< No item with index lower than this is free (doesn't say anything about this one!)
|
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 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-NULL)
|
size_t items; ///< Number of used indexes (non-NULL)
|
||||||
#ifdef OTTD_ASSERT
|
|
||||||
size_t checked; ///< Number of items we checked for
|
|
||||||
#endif /* OTTD_ASSERT */
|
|
||||||
bool cleaning; ///< True if cleaning pool (deleting all items)
|
bool cleaning; ///< True if cleaning pool (deleting all items)
|
||||||
|
|
||||||
Titem **data; ///< Pointer to array of pointers to Titem
|
Titem **data; ///< Pointer to array of pointers to Titem
|
||||||
|
@ -71,11 +68,7 @@ struct Pool {
|
||||||
*/
|
*/
|
||||||
FORCEINLINE bool CanAllocate(size_t n = 1)
|
FORCEINLINE bool CanAllocate(size_t n = 1)
|
||||||
{
|
{
|
||||||
bool ret = this->items <= Tmax_size - n;
|
return this->items <= Tmax_size - n;
|
||||||
#ifdef OTTD_ASSERT
|
|
||||||
this->checked = ret ? n : 0;
|
|
||||||
#endif /* OTTD_ASSERT */
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue