Codechange: Replace C-casts in pool functions. (#12541)

This commit is contained in:
Peter Nelson
2024-04-20 16:50:13 +01:00
committed by GitHub
parent c5ef47ee09
commit b4e00fa738
2 changed files with 8 additions and 8 deletions

View File

@@ -115,17 +115,17 @@ DEFINE_POOL_METHOD(inline void *)::AllocateItem(size_t size, size_t index)
Titem *item;
if (Tcache && this->alloc_cache != nullptr) {
assert(sizeof(Titem) == size);
item = (Titem *)this->alloc_cache;
item = reinterpret_cast<Titem *>(this->alloc_cache);
this->alloc_cache = this->alloc_cache->next;
if (Tzero) {
/* Explicitly casting to (void *) prevents a clang warning -
* we are actually memsetting a (not-yet-constructed) object */
memset((void *)item, 0, sizeof(Titem));
memset(static_cast<void *>(item), 0, sizeof(Titem));
}
} else if (Tzero) {
item = (Titem *)CallocT<uint8_t>(size);
item = reinterpret_cast<Titem *>(CallocT<uint8_t>(size));
} else {
item = (Titem *)MallocT<uint8_t>(size);
item = reinterpret_cast<Titem *>(MallocT<uint8_t>(size));
}
this->data[index] = item;
SetBit(this->used_bitmap[index / BITMAP_SIZE], index % BITMAP_SIZE);
@@ -188,7 +188,7 @@ DEFINE_POOL_METHOD(void)::FreeItem(size_t index)
assert(index < this->size);
assert(this->data[index] != nullptr);
if (Tcache) {
AllocCache *ac = (AllocCache *)this->data[index];
AllocCache *ac = reinterpret_cast<AllocCache *>(this->data[index]);
ac->next = this->alloc_cache;
this->alloc_cache = ac;
} else {