include: Introduce void_ptr_offset.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
This commit is contained in:
Philip Rebohle 2020-10-22 18:40:09 +02:00 committed by Hans-Kristian Arntzen
parent 15b1fb7128
commit 36bdc02a05
2 changed files with 7 additions and 7 deletions

View File

@ -50,14 +50,9 @@ struct hash_map
uint32_t used_count;
};
static inline void *hash_map_ptr_offset(void *ptr, size_t offset)
{
return ((char*)ptr) + offset;
}
static inline struct hash_map_entry *hash_map_get_entry(struct hash_map *hash_map, uint32_t entry_idx)
{
return hash_map_ptr_offset(hash_map->entries, hash_map->entry_size * entry_idx);
return void_ptr_offset(hash_map->entries, hash_map->entry_size * entry_idx);
}
static inline uint32_t hash_map_get_entry_idx(struct hash_map *hash_map, uint32_t hash_value)
@ -98,7 +93,7 @@ static inline bool hash_map_grow(struct hash_map *hash_map)
for (i = 0; i < old_count; i++)
{
/* Relocate existing entries one by one */
struct hash_map_entry *old_entry = hash_map_ptr_offset(old_entries, i * hash_map->entry_size);
struct hash_map_entry *old_entry = void_ptr_offset(old_entries, i * hash_map->entry_size);
if (old_entry->flags & HASH_MAP_ENTRY_OCCUPIED)
{

View File

@ -271,4 +271,9 @@ static inline size_t vkd3d_wcslen(const WCHAR *wstr, size_t wchar_size)
}
}
static inline void *void_ptr_offset(void *ptr, size_t offset)
{
return ((char*)ptr) + offset;
}
#endif /* __VKD3D_COMMON_H */