Quellcode durchsuchen

Be consistent about using `size_t` instead of `std::size_t`

Michael Ragazzon vor 1 Jahr
Ursprung
Commit
5ec648c5fb

+ 3 - 3
Include/RmlUi/Core/StyleSheetTypes.h

@@ -102,7 +102,7 @@ using MediaBlockList = Vector<MediaBlock>;
  */
 struct StyleSheetIndex {
 	using NodeList = Vector<const StyleSheetNode*>;
-	using NodeIndex = UnorderedMap<std::size_t, NodeList>;
+	using NodeIndex = UnorderedMap<size_t, NodeList>;
 
 	// The following objects are given in prioritized order. Any nodes in the first object will not be contained in the next one and so on.
 	NodeIndex ids, classes, tags;
@@ -114,9 +114,9 @@ namespace std {
 // Hash specialization for the node list, so it can be used as key in UnorderedMap.
 template <>
 struct hash<::Rml::StyleSheetIndex::NodeList> {
-	std::size_t operator()(const ::Rml::StyleSheetIndex::NodeList& nodes) const noexcept
+	size_t operator()(const ::Rml::StyleSheetIndex::NodeList& nodes) const noexcept
 	{
-		std::size_t seed = 0;
+		size_t seed = 0;
 		for (const ::Rml::StyleSheetNode* node : nodes)
 			::Rml::Utilities::HashCombine(seed, node);
 		return seed;

+ 1 - 1
Include/RmlUi/Core/Types.h

@@ -33,6 +33,7 @@
 #include "Traits.h"
 #include <cstdlib>
 #include <memory>
+#include <stddef.h>
 #include <stdint.h>
 
 namespace Rml {
@@ -40,7 +41,6 @@ namespace Rml {
 // Commonly used basic types
 using byte = unsigned char;
 using ScriptObject = void*;
-using std::size_t;
 
 enum class Character : char32_t { Null, Replacement = 0xfffd }; // Unicode code point
 enum class BoxArea { Margin, Border, Padding, Content, Auto };

+ 1 - 1
Include/RmlUi/Core/Utilities.h

@@ -36,7 +36,7 @@ namespace Rml {
 namespace Utilities {
 
 	template <class T>
-	inline void HashCombine(std::size_t& seed, const T& v)
+	inline void HashCombine(size_t& seed, const T& v)
 	{
 		Hash<T> hasher;
 		seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);

+ 1 - 1
Samples/basic/data_binding/src/main.cpp

@@ -200,7 +200,7 @@ namespace InvadersExample {
 		{
 			if (arguments.size() != 1)
 				return;
-			const std::size_t index = arguments[0].Get<std::size_t>();
+			const size_t index = arguments[0].Get<size_t>();
 			if (index >= invaders.size())
 				return;
 

+ 3 - 3
Source/Core/Layout/LayoutPools.cpp

@@ -46,10 +46,10 @@ struct LayoutChunk {
 	alignas(std::max_align_t) byte buffer[Size];
 };
 
-static constexpr std::size_t ChunkSizeBig = std::max({sizeof(BlockContainer)});
-static constexpr std::size_t ChunkSizeMedium =
+static constexpr size_t ChunkSizeBig = std::max({sizeof(BlockContainer)});
+static constexpr size_t ChunkSizeMedium =
 	std::max({sizeof(InlineContainer), sizeof(InlineBox), sizeof(RootBox), sizeof(FlexContainer), sizeof(TableWrapper)});
-static constexpr std::size_t ChunkSizeSmall =
+static constexpr size_t ChunkSizeSmall =
 	std::max({sizeof(ReplacedBox), sizeof(InlineLevelBox_Text), sizeof(InlineLevelBox_Atomic), sizeof(LineBox), sizeof(FloatedBoxSpace)});
 
 static Pool<LayoutChunk<ChunkSizeBig>> layout_chunk_pool_big(50, true);

+ 6 - 4
Source/Core/Profiling.cpp

@@ -29,19 +29,21 @@
 #include "../../Include/RmlUi/Core/Profiling.h"
 
 #ifdef RMLUI_TRACY_MEMORY_PROFILING
-	#include <memory>
+	#include <cstdlib>
+	#include <stddef.h>
 
-void* operator new(std::size_t n)
+void* operator new(size_t n)
 {
 	// Overload global new and delete for memory inspection
-	void* ptr = malloc(n);
+	void* ptr = std::malloc(n);
 	TracyAlloc(ptr, n);
 	return ptr;
 }
+
 void operator delete(void* ptr) noexcept
 {
 	TracyFree(ptr);
-	free(ptr);
+	std::free(ptr);
 }
 
 #endif