NFC: pointer_offset* functions always return void*
This requires that the caller perform the cast on the output rather than the input, which is a little closer to the truth. Shuffle some casts into the right position.
This commit is contained in:
committed by
Matthew Parkinson
parent
f295a3f191
commit
cbab7a3455
@@ -18,19 +18,19 @@ namespace snmalloc
|
||||
/**
|
||||
* Perform pointer arithmetic and return the adjusted pointer.
|
||||
*/
|
||||
template<typename T>
|
||||
inline T* pointer_offset(T* base, size_t diff)
|
||||
template<typename U = void, typename T>
|
||||
inline U* pointer_offset(T* base, size_t diff)
|
||||
{
|
||||
return reinterpret_cast<T*>(reinterpret_cast<char*>(base) + diff);
|
||||
return reinterpret_cast<U*>(reinterpret_cast<char*>(base) + diff);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform pointer arithmetic and return the adjusted pointer.
|
||||
*/
|
||||
template<typename T>
|
||||
inline T* pointer_offset_signed(T* base, ptrdiff_t diff)
|
||||
template<typename U = void, typename T>
|
||||
inline U* pointer_offset_signed(T* base, ptrdiff_t diff)
|
||||
{
|
||||
return reinterpret_cast<T*>(reinterpret_cast<char*>(base) + diff);
|
||||
return reinterpret_cast<U*>(reinterpret_cast<char*>(base) + diff);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace snmalloc
|
||||
|
||||
SNMALLOC_FAST_PATH T* get_next()
|
||||
{
|
||||
return pointer_offset_signed(static_cast<T*>(this), to_next);
|
||||
return pointer_offset_signed<T>(this, to_next);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user