| 80 | return ((b & (1u<<j))!=0); |
| 81 | } |
| 82 | __forceinline char * allocate ( ) { |
| 83 | if ( allocated == total ) return nullptr; |
| 84 | uint64_t maxt = total / 32; |
| 85 | for ( uint64_t t=0; t!=maxt; ++t ) { |
| 86 | uint32_t b = bits[look]; |
| 87 | uint32_t nb = ~b; |
| 88 | if ( nb ) { |
| 89 | uint32_t j = 31 - das_clz(nb); |
| 90 | bits[look] = b | (1u<<j); |
| 91 | allocated ++; |
| 92 | uint64_t ofs = (look * 32 + j); |
| 93 | DAS_ASSERT(ofs < total); |
| 94 | return data + ofs * size; |
| 95 | } |
| 96 | look = look + 1; |
| 97 | if ( look == maxt ) look = 0; |
| 98 | } |
| 99 | DAS_ASSERT(0 && "allocated reports room, but no bits are available"); |
| 100 | return nullptr; |
| 101 | } |
| 102 | __forceinline void free ( char * ptr ) { |
| 103 | ptrdiff_t idx = (ptr - data) / size; |
| 104 | DAS_ASSERT ( idx>=0 && idx<ptrdiff_t(total) ); |
no test coverage detected