@@ -538,6 +538,7 @@ namespace hud
538538 return set_memory (buffer, buffer_size * sizeof (type_t ), value);
539539 }
540540
541+ private:
541542 /* *
542543 * Sets the first `size` bytes of the block of memory pointed to by `destination` to the specified `value`.
543544 * This safe version ensures that the operation is not removed by the compiler due to optimization.
@@ -561,6 +562,7 @@ namespace hud
561562 // return destination;
562563 }
563564
565+ public:
564566 /* *
565567 * Sets the first `size` bytes of the block of memory pointed to by `destination` to the specified `value`.
566568 * This safe version ensures that the operation is not removed by the compiler due to optimization.
@@ -715,19 +717,6 @@ namespace hud
715717 return static_cast <type_t *>(set_memory_zero (buffer, buffer_size * sizeof (type_t )));
716718 }
717719
718- /* *
719- * Sets the first `size` bytes of the block of memory pointed by `destination` to zero.
720- * This safe version ensures that the operation is not removed by the compiler due to optimization.
721- * `destination` is volatile to prevent memset to be remove by the compiler optimisation
722- * @param destination Pointer to the buffer. Must not be null.
723- * @param size Number of bytes to set to zero
724- * @return Pointer to the buffer `destination`.
725- */
726- static HD_FORCEINLINE void *set_memory_zero_safe (void *destination, const usize size) noexcept
727- {
728- return set_memory_safe (destination, size, 0 );
729- }
730-
731720 /* *
732721 * Sets the first `size` bytes of the block of memory pointed by `destination` to zero.
733722 * This safe version ensures that the operation is not removed by the compiler due to optimization.
@@ -751,7 +740,7 @@ namespace hud
751740 * @return Pointer to the buffer `destination`.
752741 */
753742 template <typename type_t >
754- requires (!hud::is_integral_v<type_t > && !hud::is_pointer_v<type_t >)
743+ requires (!hud::is_integral_v<type_t > && !hud::is_pointer_v<type_t > && hud::is_trivially_copyable_v< type_t > )
755744 static HD_FORCEINLINE type_t *set_memory_zero_safe (type_t *destination, const usize size) noexcept
756745 {
757746 return set_memory_safe (destination, size, 0 );
@@ -782,7 +771,7 @@ namespace hud
782771 // LCOV_EXCL_STOP
783772 else
784773 {
785- return static_cast <type_t *>(set_memory_safe (static_cast < void *>( destination) , size, 0 ));
774+ return static_cast <type_t *>(set_memory_safe (destination, size, 0 ));
786775 }
787776 }
788777
@@ -811,7 +800,7 @@ namespace hud
811800 // LCOV_EXCL_STOP
812801 else
813802 {
814- return static_cast <type_t *>(set_memory_zero_safe ( static_cast < void *>( destination) , size));
803+ return static_cast <type_t *>(set_memory_safe ( destination, size, 0 ));
815804 }
816805 }
817806
@@ -825,9 +814,10 @@ namespace hud
825814 * @return Pointer to the `buffer`.
826815 */
827816 template <typename type_t , usize buffer_size>
817+ requires (hud::is_trivially_copyable_v<type_t >)
828818 static HD_FORCEINLINE constexpr type_t *set_memory_zero_safe (type_t (&buffer)[buffer_size]) noexcept
829819 {
830- return static_cast <type_t *>(set_memory_zero_safe (buffer, buffer_size * sizeof (type_t )));
820+ return static_cast <type_t *>(set_memory_safe (buffer, buffer_size * sizeof (type_t ), 0 ));
831821 }
832822
833823 /* *
0 commit comments