src/oldpool_func.h
changeset 9661 7bfc9b673b17
parent 9111 48ce04029fe4
child 10304 ca65c08875e2
equal deleted inserted replaced
9660:2bc15fc4dcf6 9661:7bfc9b673b17
    15  */
    15  */
    16 template<typename T, typename Tid, OldMemoryPool<T> *Tpool> T *PoolItem<T, Tid, Tpool>::AllocateSafeRaw(uint &first)
    16 template<typename T, typename Tid, OldMemoryPool<T> *Tpool> T *PoolItem<T, Tid, Tpool>::AllocateSafeRaw(uint &first)
    17 {
    17 {
    18 	uint last_minus_one = Tpool->GetSize() - 1;
    18 	uint last_minus_one = Tpool->GetSize() - 1;
    19 
    19 
    20 	for (T *t = Tpool->Get(first); t != NULL; t = (t->index < last_minus_one) ? Tpool->Get(t->index + 1U) : NULL) {
    20 	for (T *t = Tpool->Get(first); t != NULL; t = ((uint)t->index < last_minus_one) ? Tpool->Get(t->index + 1U) : NULL) {
    21 		if (!t->IsValid()) {
    21 		if (!t->IsValid()) {
    22 			first = t->index;
    22 			first = t->index;
    23 			Tid index = t->index;
    23 			Tid index = t->index;
    24 
    24 
    25 			memset(t, 0, Tpool->item_size);
    25 			memset(t, 0, Tpool->item_size);
    42  */
    42  */
    43 template<typename T, typename Tid, OldMemoryPool<T> *Tpool> bool PoolItem<T, Tid, Tpool>::CanAllocateItem()
    43 template<typename T, typename Tid, OldMemoryPool<T> *Tpool> bool PoolItem<T, Tid, Tpool>::CanAllocateItem()
    44 {
    44 {
    45 	uint last_minus_one = Tpool->GetSize() - 1;
    45 	uint last_minus_one = Tpool->GetSize() - 1;
    46 
    46 
    47 	for (T *t = Tpool->Get(Tpool->first_free_index); t != NULL; t = (t->index < last_minus_one) ? Tpool->Get(t->index + 1U) : NULL) {
    47 	for (T *t = Tpool->Get(Tpool->first_free_index); t != NULL; t = ((uint)t->index < last_minus_one) ? Tpool->Get(t->index + 1U) : NULL) {
    48 		if (!t->IsValid()) return true;
    48 		if (!t->IsValid()) return true;
    49 		Tpool->first_free_index = t->index;
    49 		Tpool->first_free_index = t->index;
    50 	}
    50 	}
    51 
    51 
    52 	/* Check if we can add a block to the pool */
    52 	/* Check if we can add a block to the pool */