Explorar el Código

CreateString and FormatString: Remove the now unused `max_size` argument from API

Michael Ragazzon hace 1 año
padre
commit
553b6f41fe
Se han modificado 41 ficheros con 134 adiciones y 137 borrados
  1. 1 1
      Backends/RmlUi_Backend_SDL_SDLrenderer.cpp
  2. 1 1
      Backends/RmlUi_BackwardCompatible/RmlUi_Renderer_BackwardCompatible_GL3.cpp
  3. 2 2
      Backends/RmlUi_Renderer_GL3.cpp
  4. 3 3
      Backends/RmlUi_Renderer_VK.cpp
  5. 4 4
      Include/RmlUi/Core/StringUtilities.h
  6. 11 11
      Include/RmlUi/Core/TypeConverter.inl
  7. 1 1
      Samples/basic/animation/src/main.cpp
  8. 2 2
      Samples/basic/benchmark/src/main.cpp
  9. 1 1
      Samples/basic/custom_log/src/SystemInterface.cpp
  10. 2 3
      Samples/basic/data_binding/src/main.cpp
  11. 2 2
      Samples/basic/demo/src/DemoEventListener.cpp
  12. 2 2
      Samples/basic/demo/src/DemoWindow.cpp
  13. 4 4
      Samples/invaders/src/Game.cpp
  14. 1 1
      Samples/invaders/src/HighScores.cpp
  15. 4 4
      Samples/lua_invaders/src/Game.cpp
  16. 1 1
      Samples/lua_invaders/src/HighScores.cpp
  17. 1 1
      Source/Core/ComputeProperty.cpp
  18. 13 13
      Source/Core/DataExpression.cpp
  19. 1 1
      Source/Core/DataTypeRegister.cpp
  20. 9 9
      Source/Core/DecoratorTiled.cpp
  21. 1 1
      Source/Core/Elements/InputTypeRange.cpp
  22. 1 1
      Source/Core/EventDispatcher.cpp
  23. 2 2
      Source/Core/Layout/BlockFormattingContext.cpp
  24. 1 1
      Source/Core/Log.cpp
  25. 1 1
      Source/Core/LogDefault.cpp
  26. 2 2
      Source/Core/StringUtilities.cpp
  27. 2 2
      Source/Core/TypeConverter.cpp
  28. 7 7
      Source/Debugger/ElementInfo.cpp
  29. 1 1
      Source/Debugger/ElementLog.cpp
  30. 1 1
      Tests/Source/Benchmarks/DataBinding.cpp
  31. 4 4
      Tests/Source/Benchmarks/Element.cpp
  32. 1 1
      Tests/Source/Benchmarks/FontEffect.cpp
  33. 6 6
      Tests/Source/Benchmarks/Selectors.cpp
  34. 12 13
      Tests/Source/Common/TestsShell.cpp
  35. 3 4
      Tests/Source/UnitTests/Animation.cpp
  36. 1 1
      Tests/Source/UnitTests/Element.cpp
  37. 3 3
      Tests/Source/UnitTests/Localization.cpp
  38. 5 5
      Tests/Source/UnitTests/StringUtilities.cpp
  39. 2 2
      Tests/Source/VisualTests/CaptureScreen.cpp
  40. 8 8
      Tests/Source/VisualTests/TestNavigator.cpp
  41. 4 4
      Tests/Source/VisualTests/TestViewer.cpp

+ 1 - 1
Backends/RmlUi_Backend_SDL_SDLrenderer.cpp

@@ -93,7 +93,7 @@ bool Backend::Initialize(const char* window_name, int width, int height, bool al
 	SDL_RendererInfo renderer_info;
 	if (SDL_GetRendererInfo(renderer, &renderer_info) == 0)
 	{
-		data->system_interface.LogMessage(Rml::Log::LT_INFO, Rml::CreateString(128, "Using SDL renderer: %s\n", renderer_info.name));
+		data->system_interface.LogMessage(Rml::Log::LT_INFO, Rml::CreateString("Using SDL renderer: %s\n", renderer_info.name));
 	}
 
 	return true;

+ 1 - 1
Backends/RmlUi_BackwardCompatible/RmlUi_Renderer_BackwardCompatible_GL3.cpp

@@ -779,7 +779,7 @@ bool RmlGL3::Initialize(Rml::String* out_message)
 	}
 
 	if (out_message)
-		*out_message = Rml::CreateString(128, "Loaded OpenGL %d.%d.", GLAD_VERSION_MAJOR(gl_version), GLAD_VERSION_MINOR(gl_version));
+		*out_message = Rml::CreateString("Loaded OpenGL %d.%d.", GLAD_VERSION_MAJOR(gl_version), GLAD_VERSION_MINOR(gl_version));
 #endif
 
 	return true;

+ 2 - 2
Backends/RmlUi_Renderer_GL3.cpp

@@ -939,7 +939,7 @@ void RenderInterface_GL3::EndFrame()
 	else
 		glDisable(GL_SCISSOR_TEST);
 
-	if(glstate_backup.enable_depth_test)
+	if (glstate_backup.enable_depth_test)
 		glEnable(GL_DEPTH_TEST);
 	else
 		glDisable(GL_DEPTH_TEST);
@@ -2145,7 +2145,7 @@ bool RmlGL3::Initialize(Rml::String* out_message)
 	}
 
 	if (out_message)
-		*out_message = Rml::CreateString(128, "Loaded OpenGL %d.%d.", GLAD_VERSION_MAJOR(gl_version), GLAD_VERSION_MINOR(gl_version));
+		*out_message = Rml::CreateString("Loaded OpenGL %d.%d.", GLAD_VERSION_MAJOR(gl_version), GLAD_VERSION_MINOR(gl_version));
 #endif
 
 	return true;

+ 3 - 3
Backends/RmlUi_Renderer_VK.cpp

@@ -56,10 +56,10 @@ static Rml::String FormatByteSize(VkDeviceSize size) noexcept
 {
 	constexpr VkDeviceSize K = VkDeviceSize(1024);
 	if (size < K)
-		return Rml::CreateString(32, "%zu B", size);
+		return Rml::CreateString("%zu B", size);
 	else if (size < K * K)
-		return Rml::CreateString(32, "%g KB", double(size) / double(K));
-	return Rml::CreateString(32, "%g MB", double(size) / double(K * K));
+		return Rml::CreateString("%g KB", double(size) / double(K));
+	return Rml::CreateString("%g MB", double(size) / double(K * K));
 }
 
 static VKAPI_ATTR VkBool32 VKAPI_CALL MyDebugReportCallback(VkDebugUtilsMessageSeverityFlagBitsEXT severityFlags,

+ 4 - 4
Include/RmlUi/Core/StringUtilities.h

@@ -42,10 +42,10 @@ namespace Rml {
 class StringView;
 
 /// Construct a string using sprintf-style syntax.
-RMLUICORE_API String CreateString(size_t max_size, const char* format, ...) RMLUI_ATTRIBUTE_FORMAT_PRINTF(2, 3);
+RMLUICORE_API String CreateString(const char* format, ...) RMLUI_ATTRIBUTE_FORMAT_PRINTF(1, 2);
 
 /// Format to a string using sprintf-style syntax.
-RMLUICORE_API int FormatString(String& string, size_t max_size, const char* format, ...) RMLUI_ATTRIBUTE_FORMAT_PRINTF(3, 4);
+RMLUICORE_API int FormatString(String& string, const char* format, ...) RMLUI_ATTRIBUTE_FORMAT_PRINTF(2, 3);
 
 namespace StringUtilities {
 	/// Expands character-delimited list of values in a single string to a whitespace-trimmed list
@@ -80,9 +80,9 @@ namespace StringUtilities {
 	/// Decode RML characters, eg. '&lt;' to '<'
 	RMLUICORE_API String DecodeRml(const String& string);
 
-	// Replaces all occurences of 'search' in 'subject' with 'replace'.
+	// Replaces all occurrences of 'search' in 'subject' with 'replace'.
 	RMLUICORE_API String Replace(String subject, const String& search, const String& replace);
-	// Replaces all occurences of 'search' in 'subject' with 'replace'.
+	// Replaces all occurrences of 'search' in 'subject' with 'replace'.
 	RMLUICORE_API String Replace(String subject, char search, char replace);
 
 	/// Checks if a given value is a whitespace character.

+ 11 - 11
Include/RmlUi/Core/TypeConverter.inl

@@ -313,7 +313,7 @@ STRING_VECTOR_CONVERTER(Colourf, float, 4);
 	public:                                                \
 		static bool Convert(const type& src, String& dest) \
 		{                                                  \
-			if (FormatString(dest, 32, "%.3f", src) == 0)  \
+			if (FormatString(dest, "%.3f", src) == 0)      \
 				return false;                              \
 			StringUtilities::TrimTrailingDotZeros(dest);   \
 			return true;                                   \
@@ -325,43 +325,43 @@ FLOAT_STRING_CONVERTER(double);
 template <>
 class TypeConverter<int, String> {
 public:
-	static bool Convert(const int& src, String& dest) { return FormatString(dest, 32, "%d", src) > 0; }
+	static bool Convert(const int& src, String& dest) { return FormatString(dest, "%d", src) > 0; }
 };
 
 template <>
 class TypeConverter<unsigned int, String> {
 public:
-	static bool Convert(const unsigned int& src, String& dest) { return FormatString(dest, 32, "%u", src) > 0; }
+	static bool Convert(const unsigned int& src, String& dest) { return FormatString(dest, "%u", src) > 0; }
 };
 
 template <>
 class TypeConverter<long, String> {
 public:
-	static bool Convert(const long& src, String& dest) { return FormatString(dest, 32, "%ld", src) > 0; }
+	static bool Convert(const long& src, String& dest) { return FormatString(dest, "%ld", src) > 0; }
 };
 
 template <>
 class TypeConverter<unsigned long, String> {
 public:
-	static bool Convert(const unsigned long& src, String& dest) { return FormatString(dest, 32, "%lu", src) > 0; }
+	static bool Convert(const unsigned long& src, String& dest) { return FormatString(dest, "%lu", src) > 0; }
 };
 
 template <>
 class TypeConverter<long long, String> {
 public:
-	static bool Convert(const long long& src, String& dest) { return FormatString(dest, 32, "%lld", src) > 0; }
+	static bool Convert(const long long& src, String& dest) { return FormatString(dest, "%lld", src) > 0; }
 };
 
 template <>
 class TypeConverter<unsigned long long, String> {
 public:
-	static bool Convert(const unsigned long long& src, String& dest) { return FormatString(dest, 32, "%llu", src) > 0; }
+	static bool Convert(const unsigned long long& src, String& dest) { return FormatString(dest, "%llu", src) > 0; }
 };
 
 template <>
 class TypeConverter<byte, String> {
 public:
-	static bool Convert(const byte& src, String& dest) { return FormatString(dest, 32, "%hhu", src) > 0; }
+	static bool Convert(const byte& src, String& dest) { return FormatString(dest, "%hhu", src) > 0; }
 };
 
 template <>
@@ -387,19 +387,19 @@ public:
 template <>
 class TypeConverter<void*, String> {
 public:
-	static bool Convert(void* const& src, String& dest) { return FormatString(dest, 32, "%p", src) > 0; }
+	static bool Convert(void* const& src, String& dest) { return FormatString(dest, "%p", src) > 0; }
 };
 
 template <>
 class TypeConverter<ScriptInterface*, String> {
 public:
-	static bool Convert(ScriptInterface* const& src, String& dest) { return FormatString(dest, 32, "%p", static_cast<void*>(src)) > 0; }
+	static bool Convert(ScriptInterface* const& src, String& dest) { return FormatString(dest, "%p", static_cast<void*>(src)) > 0; }
 };
 
 template <>
 class TypeConverter<char, String> {
 public:
-	static bool Convert(const char& src, String& dest) { return FormatString(dest, 32, "%c", src) > 0; }
+	static bool Convert(const char& src, String& dest) { return FormatString(dest, "%c", src) > 0; }
 };
 
 template <typename SourceType, typename InternalType, int count>

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

@@ -351,7 +351,7 @@ int main(int /*argc*/, char** /*argv*/)
 			auto el = window->GetDocument()->GetElementById("fps");
 			float fps = float(count_frames) / dt;
 			count_frames = 0;
-			el->SetInnerRML(Rml::CreateString(20, "FPS: %f", fps));
+			el->SetInnerRML(Rml::CreateString("FPS: %f", fps));
 		}
 	}
 

+ 2 - 2
Samples/basic/benchmark/src/main.cpp

@@ -62,7 +62,7 @@ public:
 			int route = rand() % 50;
 			int max = (rand() % 40) + 10;
 			int value = rand() % max;
-			Rml::String rml_row = Rml::CreateString(1000, R"(
+			Rml::String rml_row = Rml::CreateString(R"(
 			<div class="row">
 				<div class="col col1"><button class="expand" index="%d">+</button>&nbsp;<a>Route %d</a></div>
 				<div class="col col23"><input type="range" class="assign_range" min="0" max="%d" value="%d"/></div>
@@ -262,7 +262,7 @@ int main(int /*argc*/, char** /*argv*/)
 
 			auto el = window->GetDocument()->GetElementById("fps");
 			count_frames = 0;
-			el->SetInnerRML(Rml::CreateString(20, "FPS: %f", fps_mean));
+			el->SetInnerRML(Rml::CreateString("FPS: %f", fps_mean));
 		}
 	}
 

+ 1 - 1
Samples/basic/custom_log/src/SystemInterface.cpp

@@ -69,7 +69,7 @@ bool SystemInterface::LogMessage(Rml::Log::Type type, const Rml::String& message
 #ifdef RMLUI_PLATFORM_WIN32
 		if (type == Rml::Log::LT_ASSERT)
 		{
-			Rml::String assert_message = Rml::CreateString(1024, "%s\nWould you like to interrupt execution?", message.c_str());
+			Rml::String assert_message = Rml::CreateString("%s\nWould you like to interrupt execution?", message.c_str());
 
 			// Return TRUE if the user presses NO (continue execution)
 			return MessageBoxA(nullptr, assert_message.c_str(), "Assertion Failure", MB_YESNO | MB_ICONSTOP | MB_DEFBUTTON2 | MB_SYSTEMMODAL) == IDNO;

+ 2 - 3
Samples/basic/data_binding/src/main.cpp

@@ -229,8 +229,7 @@ namespace InvadersExample {
 			return false;
 
 		// Register a custom getter for the Colourb type.
-		constructor.RegisterScalar<Rml::Colourb>(
-			[](const Rml::Colourb& color, Rml::Variant& variant) { variant = Rml::ToString(color); });
+		constructor.RegisterScalar<Rml::Colourb>([](const Rml::Colourb& color, Rml::Variant& variant) { variant = Rml::ToString(color); });
 		// Register a transform function for formatting time
 		constructor.RegisterTransformFunc("format_time", [](const Rml::VariantList& arguments) -> Rml::Variant {
 			if (arguments.empty())
@@ -238,7 +237,7 @@ namespace InvadersExample {
 			const double t = arguments[0].Get<double>();
 			const int minutes = int(t) / 60;
 			const double seconds = t - 60.0 * double(minutes);
-			return Rml::Variant(Rml::CreateString(10, "%02d:%05.2f", minutes, seconds));
+			return Rml::Variant(Rml::CreateString("%02d:%05.2f", minutes, seconds));
 		});
 
 		// Structs are registered by adding all their members through the returned handle.

+ 2 - 2
Samples/basic/demo/src/DemoEventListener.cpp

@@ -119,7 +119,7 @@ void DemoEventListener::ProcessEvent(Rml::Event& event)
 		demo_window->SetTweeningParameters(tweening_parameters);
 
 		if (auto el_duration = element->GetElementById("duration"))
-			el_duration->SetInnerRML(CreateString(20, "%2.2f", value));
+			el_duration->SetInnerRML(CreateString("%2.2f", value));
 	}
 	else if (value == "rating")
 	{
@@ -144,7 +144,7 @@ void DemoEventListener::ProcessEvent(Rml::Event& event)
 			else
 				emoji = emojis[Champion];
 
-			el_rating->SetInnerRML(Rml::CreateString(30, "%d%%", value));
+			el_rating->SetInnerRML(Rml::CreateString("%d%%", value));
 			el_rating_emoji->SetInnerRML(emoji);
 		}
 	}

+ 2 - 2
Samples/basic/demo/src/DemoWindow.cpp

@@ -150,8 +150,8 @@ void DemoWindow::Update()
 		float value_mapped = value_begin + value_gauge * (value_end - value_begin);
 		gauge->SetAttribute("value", value_mapped);
 
-		auto value_gauge_str = CreateString(10, "%d %%", Math::RoundToInteger(value_gauge * 100.f));
-		auto value_horizontal_str = CreateString(10, "%d %%", Math::RoundToInteger(value_horizontal * 100.f));
+		auto value_gauge_str = CreateString("%d %%", Math::RoundToInteger(value_gauge * 100.f));
+		auto value_horizontal_str = CreateString("%d %%", Math::RoundToInteger(value_horizontal * 100.f));
 
 		if (auto el_value = document->GetElementById("gauge_value"))
 			el_value->SetInnerRML(value_gauge_str);

+ 4 - 4
Samples/invaders/src/Game.cpp

@@ -212,7 +212,7 @@ void Game::SetScore(int score)
 
 	Rml::Element* score_element = context->GetDocument("game_window")->GetElementById("score");
 	if (score_element != nullptr)
-		score_element->SetInnerRML(Rml::CreateString(128, "%d", score).c_str());
+		score_element->SetInnerRML(Rml::CreateString("%d", score).c_str());
 
 	// Update the high score if we've beaten it.
 	if (score > HighScores::GetHighScore())
@@ -223,7 +223,7 @@ void Game::SetHighScore(int score)
 {
 	Rml::Element* high_score_element = context->GetDocument("game_window")->GetElementById("hiscore");
 	if (high_score_element != nullptr)
-		high_score_element->SetInnerRML(Rml::CreateString(128, "%d", score).c_str());
+		high_score_element->SetInnerRML(Rml::CreateString("%d", score).c_str());
 }
 
 void Game::SetLives(int lives)
@@ -232,7 +232,7 @@ void Game::SetLives(int lives)
 
 	Rml::Element* score_element = context->GetDocument("game_window")->GetElementById("lives");
 	if (score_element != nullptr)
-		score_element->SetInnerRML(Rml::CreateString(128, "%d", defender_lives).c_str());
+		score_element->SetInnerRML(Rml::CreateString("%d", defender_lives).c_str());
 }
 
 void Game::SetWave(int wave)
@@ -241,7 +241,7 @@ void Game::SetWave(int wave)
 
 	Rml::Element* waves_element = context->GetDocument("game_window")->GetElementById("waves");
 	if (waves_element != nullptr)
-		waves_element->SetInnerRML(Rml::CreateString(128, "%d", wave).c_str());
+		waves_element->SetInnerRML(Rml::CreateString("%d", wave).c_str());
 }
 
 void Game::RemoveLife()

+ 1 - 1
Samples/invaders/src/HighScores.cpp

@@ -176,7 +176,7 @@ void HighScores::SaveScores()
 			Rml::String colour_string;
 			Rml::TypeConverter<Rml::Colourb, Rml::String>::Convert(score.colour, colour_string);
 
-			Rml::String score_str = Rml::CreateString(1024, "%s\t%s\t%d\t%d\n", score.name.c_str(), colour_string.c_str(), score.wave, score.score);
+			Rml::String score_str = Rml::CreateString("%s\t%s\t%d\t%d\n", score.name.c_str(), colour_string.c_str(), score.wave, score.score);
 			fputs(score_str.c_str(), scores_file);
 		}
 

+ 4 - 4
Samples/lua_invaders/src/Game.cpp

@@ -210,7 +210,7 @@ void Game::SetScore(int score)
 
 	Rml::Element* score_element = context->GetDocument("game_window")->GetElementById("score");
 	if (score_element != nullptr)
-		score_element->SetInnerRML(Rml::CreateString(128, "%d", score).c_str());
+		score_element->SetInnerRML(Rml::CreateString("%d", score).c_str());
 
 	// Update the high score if we've beaten it.
 	if (score > HighScores::GetHighScore())
@@ -221,7 +221,7 @@ void Game::SetHighScore(int score)
 {
 	Rml::Element* high_score_element = context->GetDocument("game_window")->GetElementById("hiscore");
 	if (high_score_element != nullptr)
-		high_score_element->SetInnerRML(Rml::CreateString(128, "%d", score).c_str());
+		high_score_element->SetInnerRML(Rml::CreateString("%d", score).c_str());
 }
 
 void Game::SetLives(int lives)
@@ -230,7 +230,7 @@ void Game::SetLives(int lives)
 
 	Rml::Element* score_element = context->GetDocument("game_window")->GetElementById("lives");
 	if (score_element != nullptr)
-		score_element->SetInnerRML(Rml::CreateString(128, "%d", defender_lives).c_str());
+		score_element->SetInnerRML(Rml::CreateString("%d", defender_lives).c_str());
 }
 
 void Game::SetWave(int wave)
@@ -239,7 +239,7 @@ void Game::SetWave(int wave)
 
 	Rml::Element* waves_element = context->GetDocument("game_window")->GetElementById("waves");
 	if (waves_element != nullptr)
-		waves_element->SetInnerRML(Rml::CreateString(128, "%d", wave).c_str());
+		waves_element->SetInnerRML(Rml::CreateString("%d", wave).c_str());
 }
 
 void Game::RemoveLife()

+ 1 - 1
Samples/lua_invaders/src/HighScores.cpp

@@ -176,7 +176,7 @@ void HighScores::SaveScores()
 			Rml::String colour_string;
 			Rml::TypeConverter<Rml::Colourb, Rml::String>::Convert(score.colour, colour_string);
 
-			Rml::String score_str = Rml::CreateString(1024, "%s\t%s\t%d\t%d\n", score.name.c_str(), colour_string.c_str(), score.wave, score.score);
+			Rml::String score_str = Rml::CreateString("%s\t%s\t%d\t%d\n", score.name.c_str(), colour_string.c_str(), score.wave, score.score);
 			fputs(score_str.c_str(), scores_file);
 		}
 

+ 1 - 1
Source/Core/ComputeProperty.cpp

@@ -268,7 +268,7 @@ String GetFontFaceDescription(const String& font_family, Style::FontStyle style,
 	else
 		font_attributes.resize(font_attributes.size() - 2);
 
-	return CreateString(font_attributes.size() + font_family.size() + 8, "'%s' [%s]", font_family.c_str(), font_attributes.c_str());
+	return CreateString("'%s' [%s]", font_family.c_str(), font_attributes.c_str());
 }
 
 } // namespace Rml

+ 13 - 13
Source/Core/DataExpression.cpp

@@ -168,9 +168,9 @@ public:
 	{
 		const char c = Look();
 		if (c == '\0')
-			Error(CreateString(expected_symbols.size() + 50, "Expected %s but found end of string.", expected_symbols.c_str()));
+			Error(CreateString("Expected %s but found end of string.", expected_symbols.c_str()));
 		else
-			Error(CreateString(expected_symbols.size() + 50, "Expected %s but found character '%c'.", expected_symbols.c_str(), c));
+			Error(CreateString("Expected %s but found character '%c'.", expected_symbols.c_str(), c));
 	}
 	void Expected(char expected) { Expected(String(1, '\'') + expected + '\''); }
 
@@ -194,12 +194,12 @@ public:
 		if (!reached_end)
 		{
 			parse_error = true;
-			Error(CreateString(50, "Unexpected character '%c' encountered.", Look()));
+			Error(CreateString("Unexpected character '%c' encountered.", Look()));
 		}
 		if (!parse_error && program_stack_size != 0)
 		{
 			parse_error = true;
-			Error(CreateString(120, "Internal parser error, inconsistent stack operations. Stack size is %d at parse end.", program_stack_size));
+			Error(CreateString("Internal parser error, inconsistent stack operations. Stack size is %d at parse end.", program_stack_size));
 		}
 
 		return !parse_error;
@@ -246,7 +246,7 @@ public:
 		RMLUI_ASSERT(num_arguments >= 0);
 		if (program_stack_size < num_arguments)
 		{
-			Error(CreateString(128, "Internal parser error: Popping %d arguments, but the stack contains only %d elements.", num_arguments,
+			Error(CreateString("Internal parser error: Popping %d arguments, but the stack contains only %d elements.", num_arguments,
 				program_stack_size));
 			return;
 		}
@@ -284,7 +284,7 @@ private:
 		DataAddress address = expression_interface.ParseAddress(name);
 		if (address.empty())
 		{
-			Error(CreateString(name.size() + 50, "Could not find data variable with name '%s'.", name.c_str()));
+			Error(CreateString("Could not find data variable with name '%s'.", name.c_str()));
 			return;
 		}
 		int index = int(variable_addresses.size());
@@ -401,7 +401,7 @@ namespace Parse {
 		if (!first_match)
 		{
 			if (!silent)
-				parser.Error(CreateString(100, "Invalid number literal. Expected '0-9' or '.' but found '%c'.", c));
+				parser.Error(CreateString("Invalid number literal. Expected '0-9' or '.' but found '%c'.", c));
 
 			return String();
 		}
@@ -907,7 +907,7 @@ static String DumpProgram(const Program& program)
 	for (size_t i = 0; i < program.size(); i++)
 	{
 		String instruction_str = program[i].data.Get<String>();
-		str += CreateString(50 + instruction_str.size(), "  %4zu  '%c'  %s\n", i, char(program[i].instruction), instruction_str.c_str());
+		str += CreateString("  %4zu  '%c'  %s\n", i, char(program[i].instruction), instruction_str.c_str());
 	}
 	return str;
 }
@@ -986,7 +986,7 @@ private:
 			case Register::L:  L = stack.back(); stack.pop_back(); break;
 			case Register::C:  C = stack.back(); stack.pop_back(); break;
 				// clang-format on
-			default: return Error(CreateString(50, "Invalid register %d.", int(reg)));
+			default: return Error(CreateString("Invalid register %d.", int(reg)));
 			}
 		}
 		break;
@@ -1080,9 +1080,9 @@ private:
 					if (i < arguments.size() - 1)
 						arguments_str += ", ";
 				}
-				return Error(CreateString(60 + function_name.size() + arguments_str.size(), "Failed to execute %s: %s(%s)",
-					instruction == Instruction::TransformFnc ? "transform function" : "event callback", function_name.c_str(),
-					arguments_str.c_str()));
+				return Error(
+					CreateString("Failed to execute %s: %s(%s)", instruction == Instruction::TransformFnc ? "transform function" : "event callback",
+						function_name.c_str(), arguments_str.c_str()));
 			}
 		}
 		break;
@@ -1118,7 +1118,7 @@ private:
 		if (num_arguments < 0)
 			return Error("Invalid number of arguments.");
 		if (stack.size() < size_t(num_arguments))
-			return Error(CreateString(100, "Cannot pop %d arguments, stack contains only %zu elements.", num_arguments, stack.size()));
+			return Error(CreateString("Cannot pop %d arguments, stack contains only %zu elements.", num_arguments, stack.size()));
 
 		const auto it_stack_begin_arguments = stack.end() - num_arguments;
 		out_arguments.insert(out_arguments.end(), std::make_move_iterator(it_stack_begin_arguments), std::make_move_iterator(stack.end()));

+ 1 - 1
Source/Core/DataTypeRegister.cpp

@@ -83,7 +83,7 @@ DataTypeRegister::DataTypeRegister()
 
 		String format_specifier = String(remove_trailing_zeros ? "%#." : "%.") + ToString(precision) + 'f';
 		String result;
-		if (FormatString(result, 64, format_specifier.c_str(), value) == 0)
+		if (FormatString(result, format_specifier.c_str(), value) == 0)
 			return {};
 
 		if (remove_trailing_zeros)

+ 9 - 9
Source/Core/DecoratorTiled.cpp

@@ -168,17 +168,17 @@ void DecoratorTiled::Tile::GenerateGeometry(Mesh& mesh, const ComputedValues& co
 	case REPEAT:
 		final_tile_dimensions = surface_dimensions;
 		repeat_factor = surface_dimensions / tile_dimensions;
-	break;
+		break;
 	case REPEAT_X:
 		final_tile_dimensions = Vector2f(surface_dimensions.x, tile_dimensions.y);
 		repeat_factor.x = surface_dimensions.x / tile_dimensions.x;
 		offset_and_clip_tile = true;
-	break;
+		break;
 	case REPEAT_Y:
 		final_tile_dimensions = Vector2f(tile_dimensions.x, surface_dimensions.y);
 		repeat_factor.y = surface_dimensions.y / tile_dimensions.y;
 		offset_and_clip_tile = true;
-	break;
+		break;
 	}
 
 	Vector2f tile_offset(0, 0);
@@ -249,32 +249,32 @@ void DecoratorTiledInstancer::RegisterTileProperty(const String& name, bool regi
 {
 	TilePropertyIds ids = {};
 
-	ids.src = RegisterProperty(CreateString(32, "%s-src", name.c_str()), "").AddParser("string").GetId();
+	ids.src = RegisterProperty(CreateString("%s-src", name.c_str()), "").AddParser("string").GetId();
 
 	String additional_modes;
 
 	if (register_fit_modes)
 	{
-		String fit_name = CreateString(32, "%s-fit", name.c_str());
+		String fit_name = CreateString("%s-fit", name.c_str());
 		ids.fit = RegisterProperty(fit_name, "fill")
 					  .AddParser("keyword", "fill, contain, cover, scale-none, scale-down, repeat, repeat-x, repeat-y")
 					  .GetId();
 
-		String align_x_name = CreateString(32, "%s-align-x", name.c_str());
+		String align_x_name = CreateString("%s-align-x", name.c_str());
 		ids.align_x = RegisterProperty(align_x_name, "center").AddParser("keyword", "left, center, right").AddParser("length_percent").GetId();
 
-		String align_y_name = CreateString(32, "%s-align-y", name.c_str());
+		String align_y_name = CreateString("%s-align-y", name.c_str());
 		ids.align_y = RegisterProperty(align_y_name, "center").AddParser("keyword", "top, center, bottom").AddParser("length_percent").GetId();
 
 		additional_modes += ", " + fit_name + ", " + align_x_name + ", " + align_y_name;
 	}
 
-	ids.orientation = RegisterProperty(CreateString(32, "%s-orientation", name.c_str()), "none")
+	ids.orientation = RegisterProperty(CreateString("%s-orientation", name.c_str()), "none")
 						  .AddParser("keyword", "none, flip-horizontal, flip-vertical, rotate-180")
 						  .GetId();
 
 	RegisterShorthand(name,
-		CreateString(256, ("%s-src, %s-orientation" + additional_modes).c_str(), name.c_str(), name.c_str(), name.c_str(), name.c_str(), name.c_str(),
+		CreateString(("%s-src, %s-orientation" + additional_modes).c_str(), name.c_str(), name.c_str(), name.c_str(), name.c_str(), name.c_str(),
 			name.c_str()),
 		ShorthandType::FallThrough);
 

+ 1 - 1
Source/Core/Elements/InputTypeRange.cpp

@@ -45,7 +45,7 @@ InputTypeRange::~InputTypeRange()
 
 String InputTypeRange::GetValue() const
 {
-	return CreateString(32, "%f", widget->GetValue());
+	return CreateString("%f", widget->GetValue());
 }
 
 void InputTypeRange::OnUpdate()

+ 1 - 1
Source/Core/EventDispatcher.cpp

@@ -257,7 +257,7 @@ String EventDispatcher::ToString() const
 
 	auto add_to_result = [&result](EventId id, int count) {
 		const EventSpecification& specification = EventSpecificationInterface::Get(id);
-		result += CreateString(specification.type.size() + 32, "%s (%d), ", specification.type.c_str(), count);
+		result += CreateString("%s (%d), ", specification.type.c_str(), count);
 	};
 
 	EventId previous_id = listeners[0].id;

+ 2 - 2
Source/Core/Layout/BlockFormattingContext.cpp

@@ -118,7 +118,7 @@ UniquePtr<LayoutBox> BlockFormattingContext::Format(ContainerBox* parent_contain
 
 #ifdef RMLUI_TRACY_PROFILING
 	RMLUI_ZoneScopedC(0xB22222);
-	auto name = CreateString(80, "%s %x", element->GetAddress(false, false).c_str(), element);
+	auto name = CreateString("%s %x", element->GetAddress(false, false).c_str(), element);
 	RMLUI_ZoneName(name.c_str(), name.size());
 #endif
 
@@ -214,7 +214,7 @@ bool BlockFormattingContext::FormatBlockContainerChild(BlockContainer* parent_co
 {
 #ifdef RMLUI_TRACY_PROFILING
 	RMLUI_ZoneScoped;
-	auto name = CreateString(80, ">%s %x", element->GetAddress(false, false).c_str(), element);
+	auto name = CreateString(">%s %x", element->GetAddress(false, false).c_str(), element);
 	RMLUI_ZoneName(name.c_str(), name.size());
 #endif
 

+ 1 - 1
Source/Core/Log.cpp

@@ -82,7 +82,7 @@ void Log::ParseError(const String& filename, int line_number, const char* fmt, .
 
 bool Assert(const char* msg, const char* file, int line)
 {
-	String message = CreateString(1024, "%s\n%s:%d", msg, file, line);
+	String message = CreateString("%s\n%s:%d", msg, file, line);
 
 	bool result = true;
 	if (SystemInterface* system_interface = GetSystemInterface())

+ 1 - 1
Source/Core/LogDefault.cpp

@@ -43,7 +43,7 @@ bool LogDefault::LogMessage(Log::Type type, const String& message)
 	#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
 	if (type == Log::LT_ASSERT)
 	{
-		String message_user = CreateString(1024, "%s\nWould you like to interrupt execution?", message.c_str());
+		String message_user = CreateString("%s\nWould you like to interrupt execution?", message.c_str());
 
 		// Return TRUE if the user presses NO (continue execution)
 		return (IDNO == MessageBoxA(nullptr, message_user.c_str(), "Assertion Failure", MB_YESNO | MB_ICONSTOP | MB_DEFBUTTON2 | MB_TASKMODAL));

+ 2 - 2
Source/Core/StringUtilities.cpp

@@ -76,7 +76,7 @@ static int FormatString(String& string, const char* format, va_list argument_lis
 	return length;
 }
 
-int FormatString(String& string, size_t /*max_size*/, const char* format, ...)
+int FormatString(String& string, const char* format, ...)
 {
 	va_list argument_list;
 	va_start(argument_list, format);
@@ -84,7 +84,7 @@ int FormatString(String& string, size_t /*max_size*/, const char* format, ...)
 	va_end(argument_list);
 	return result;
 }
-String CreateString(size_t /*max_size*/, const char* format, ...)
+String CreateString(const char* format, ...)
 {
 	String result;
 	va_list argument_list;

+ 2 - 2
Source/Core/TypeConverter.cpp

@@ -295,9 +295,9 @@ bool TypeConverter<BoxShadowList, String>::Convert(const BoxShadowList& src, Str
 bool TypeConverter<Colourb, String>::Convert(const Colourb& src, String& dest)
 {
 	if (src.alpha == 255)
-		return FormatString(dest, 32, "#%02hhx%02hhx%02hhx", src.red, src.green, src.blue) > 0;
+		return FormatString(dest, "#%02hhx%02hhx%02hhx", src.red, src.green, src.blue) > 0;
 	else
-		return FormatString(dest, 32, "#%02hhx%02hhx%02hhx%02hhx", src.red, src.green, src.blue, src.alpha) > 0;
+		return FormatString(dest, "#%02hhx%02hhx%02hhx%02hhx", src.red, src.green, src.blue, src.alpha) > 0;
 }
 
 bool TypeConverter<String, Colourb>::Convert(const String& src, Colourb& dest)

+ 7 - 7
Source/Debugger/ElementInfo.cpp

@@ -448,13 +448,13 @@ void ElementInfo::UpdateSourceElement()
 					name = "id";
 					value = source_element->GetId();
 					if (!value.empty())
-						attributes += CreateString(name.size() + value.size() + 32, "%s: <em>%s</em><br />", name.c_str(), value.c_str());
+						attributes += CreateString("%s: <em>%s</em><br />", name.c_str(), value.c_str());
 				}
 				{
 					name = "class";
 					value = source_element->GetClassNames();
 					if (!value.empty())
-						attributes += CreateString(name.size() + value.size() + 32, "%s: <em>%s</em><br />", name.c_str(), value.c_str());
+						attributes += CreateString("%s: <em>%s</em><br />", name.c_str(), value.c_str());
 				}
 			}
 
@@ -464,14 +464,14 @@ void ElementInfo::UpdateSourceElement()
 				auto& variant = pair.second;
 				String value = StringUtilities::EncodeRml(variant.Get<String>());
 				if (name != "class" && name != "style" && name != "id")
-					attributes += CreateString(name.size() + value.size() + 32, "%s: <em>%s</em><br />", name.c_str(), value.c_str());
+					attributes += CreateString("%s: <em>%s</em><br />", name.c_str(), value.c_str());
 			}
 
 			// Text is not an attribute but useful nonetheless
 			if (auto text_element = rmlui_dynamic_cast<ElementText*>(source_element))
 			{
 				const String& text_content = text_element->GetText();
-				attributes += CreateString(text_content.size() + 32, "Text: <em>%s</em><br />", text_content.c_str());
+				attributes += CreateString("Text: <em>%s</em><br />", text_content.c_str());
 			}
 		}
 
@@ -548,7 +548,7 @@ void ElementInfo::UpdateSourceElement()
 					ToString(box.GetEdge(BoxArea::Padding, edge1));
 				const String edge2_str = ToString(box.GetEdge(BoxArea::Padding, edge2)) + "|" + ToString(box.GetEdge(BoxArea::Border, edge2)) + "|" +
 					ToString(box.GetEdge(BoxArea::Margin, edge2));
-				return CreateString(256, "%s &lt;%s&gt; %s", edge1_str.c_str(), ToString(content_size).c_str(), edge2_str.c_str());
+				return CreateString("%s &lt;%s&gt; %s", edge1_str.c_str(), ToString(content_size).c_str(), edge2_str.c_str());
 			};
 
 			position = "<span class='name'>left: </span><em>" + ToString(element_offset.x) + "px</em><br/>" +                                 //
@@ -579,7 +579,7 @@ void ElementInfo::UpdateSourceElement()
 		while (element_ancestor)
 		{
 			String ancestor_name = element_ancestor->GetAddress(false, false);
-			ancestors += CreateString(ancestor_name.size() + 32, "<p id=\"a %d\">%s</p>", ancestor_depth, ancestor_name.c_str());
+			ancestors += CreateString("<p id=\"a %d\">%s</p>", ancestor_depth, ancestor_name.c_str());
 			element_ancestor = element_ancestor->GetParentNode();
 			ancestor_depth++;
 		}
@@ -620,7 +620,7 @@ void ElementInfo::UpdateSourceElement()
 
 				const char* non_dom_string = (i >= num_dom_children ? " class=\"non_dom\"" : "");
 
-				children += CreateString(child_name.size() + 40, "<p id=\"c %d\"%s>%s</p>", i, non_dom_string, child_name.c_str());
+				children += CreateString("<p id=\"c %d\"%s>%s</p>", i, non_dom_string, child_name.c_str());
 			}
 		}
 

+ 1 - 1
Source/Debugger/ElementLog.cpp

@@ -210,7 +210,7 @@ void ElementLog::OnUpdate()
 			int num_messages = 0;
 			while (next_type != -1 && num_messages < MAX_LOG_MESSAGES)
 			{
-				messages += CreateString(128, "<div class=\"log-entry\"><div class=\"icon %s\">%s</div><p class=\"message\">",
+				messages += CreateString("<div class=\"log-entry\"><div class=\"icon %s\">%s</div><p class=\"message\">",
 					log_types[next_type].class_name.c_str(), log_types[next_type].alert_contents.c_str());
 				messages += log_types[next_type].log_messages[log_pointers[next_type]].message;
 				messages += "</p></div>";

+ 1 - 1
Tests/Source/Benchmarks/DataBinding.cpp

@@ -227,7 +227,7 @@ TEST_CASE("data_binding")
 
 		bench.run("Reference (Arrays)", [&] {
 			element_array->SetInnerRML(
-				Rml::CreateString(128, "<span>%d </span><span>%d </span><span>%d </span>", rng.bounded(5000), rng.bounded(5000), rng.bounded(5000)));
+				Rml::CreateString("<span>%d </span><span>%d </span><span>%d </span>", rng.bounded(5000), rng.bounded(5000), rng.bounded(5000)));
 			context->Update();
 		});
 

+ 4 - 4
Tests/Source/Benchmarks/Element.cpp

@@ -52,7 +52,7 @@ static const String document_rml = R"(
 			width: 1300px;
 			height: 600px;
 		}
-		#performance 
+		#performance
 		{
 			width: 800px;
 			height: 300px;
@@ -122,7 +122,7 @@ static String GenerateRml(const int num_rows, const char* row)
 		int route = rng() % 50;
 		int max = (rng() % 40) + 10;
 		int value = rng() % max;
-		Rml::String rml_row = Rml::CreateString(10000, row, index, route, max, value);
+		Rml::String rml_row = Rml::CreateString(row, index, route, max, value);
 		rml += rml_row;
 	}
 
@@ -148,7 +148,7 @@ TEST_CASE("element.creation_and_destruction")
 	context->Render();
 	TestsShell::RenderLoop();
 
-	String msg = Rml::CreateString(128, "\nElement construction and destruction of %d total elements.\n", GetNumDescendentElements(el));
+	String msg = Rml::CreateString("\nElement construction and destruction of %d total elements.\n", GetNumDescendentElements(el));
 	msg += TestsShell::GetRenderStats();
 	MESSAGE(msg);
 
@@ -211,7 +211,7 @@ TEST_CASE("element.long_texts")
 	context->Render();
 	TestsShell::RenderLoop();
 
-	String msg = Rml::CreateString(128, "\nElement construction and destruction of %d total very long elements.\n", GetNumDescendentElements(el));
+	String msg = Rml::CreateString("\nElement construction and destruction of %d total very long elements.\n", GetNumDescendentElements(el));
 	msg += TestsShell::GetRenderStats();
 	MESSAGE(msg);
 

+ 1 - 1
Tests/Source/Benchmarks/FontEffect.cpp

@@ -68,7 +68,7 @@ TEST_CASE("font_effect")
 	{
 		constexpr int effect_size = 8;
 
-		const String rml_document = CreateString(rml_font_effect_document.size() + 100, rml_font_effect_document.c_str(), effect_name, effect_size);
+		const String rml_document = CreateString(rml_font_effect_document.c_str(), effect_name, effect_size);
 
 		ElementDocument* document = context->LoadDocumentFromMemory(rml_document);
 		document->Show();

+ 6 - 6
Tests/Source/Benchmarks/Selectors.cpp

@@ -40,7 +40,7 @@ using namespace Rml;
 static constexpr const char* document_rml_template = R"(
 <rml>
 <head>
-	
+
 	<title>Benchmark Sample</title>
 	<link type="text/template" href="/assets/window.rml"/>
 	<style>
@@ -61,7 +61,7 @@ static constexpr const char* document_rml_template = R"(
 			width: 1300px;
 			height: 600px;
 		}
-		#performance 
+		#performance
 		{
 			width: 800px;
 			height: 300px;
@@ -151,7 +151,7 @@ static String GenerateRCSS(SelectorFlags selectors, const String& complex_select
 			result += GenerateRule(name);
 
 			// Set a property that does not require a layout change
-			result += CreateString(64, " { scrollbar-margin: %dpx; }\n", int(c - 'a') + 1);
+			result += CreateString(" { scrollbar-margin: %dpx; }\n", int(c - 'a') + 1);
 
 #if 1
 			// This conditions ensures that only a single version of the complex selector is included. This can be disabled to test how well the rules
@@ -181,7 +181,7 @@ static String GenerateRml(const int num_rows)
 		int value = rng() % max;
 		String class_name_a = char('a' + char(rng() % 26)) + ToString(rng() % num_rule_iterations);
 		String class_name_b = char('a' + char(rng() % 26)) + ToString(rng() % num_rule_iterations);
-		Rml::String rml_row = Rml::CreateString(1000, R"(
+		Rml::String rml_row = Rml::CreateString(R"(
 			<div class="row">
 				<div class="col col1"><button class="expand" index="%d">+</button>&nbsp;<a>Route %d</a></div>
 				<div class="col col23"><input type="range" class="assign_range" min="0" max="%d" value="%d"/></div>
@@ -256,7 +256,7 @@ TEST_CASE("Selectors")
 		else
 			styles = GenerateRCSS(selector_flags, complex_selector, name);
 
-		const String compiled_document_rml = Rml::CreateString(1000 + styles.size(), document_rml_template, styles.c_str());
+		const String compiled_document_rml = Rml::CreateString(document_rml_template, styles.c_str());
 
 		ElementDocument* document = context->LoadDocumentFromMemory(compiled_document_rml);
 		document->Show();
@@ -268,7 +268,7 @@ TEST_CASE("Selectors")
 
 		if (reference)
 		{
-			String msg = Rml::CreateString(128, "\nElement update after pseudo class change with %d descendant elements and %d unique RCSS rules.",
+			String msg = Rml::CreateString("\nElement update after pseudo class change with %d descendant elements and %d unique RCSS rules.",
 				GetNumDescendentElements(el), num_rule_iterations * 26);
 			MESSAGE(msg);
 

+ 12 - 13
Tests/Source/Common/TestsShell.cpp

@@ -194,19 +194,18 @@ Rml::String TestsShell::GetRenderStats()
 	shell_context->Render();
 	auto& counters = shell_render_interface.GetCounters();
 
-	result = Rml::CreateString(256,
-		"Context::Render() stats:\n"
-		"  Compile geometry: %zu\n"
-		"  Render geometry: %zu\n"
-		"  Release geometry: %zu\n"
-		"  Texture load: %zu\n"
-		"  Texture generate: %zu\n"
-		"  Texture release: %zu\n"
-		"  Scissor enable: %zu\n"
-		"  Scissor set: %zu\n"
-		"  Clip mask enable: %zu\n"
-		"  Clip mask render: %zu\n"
-		"  Transform set: %zu",
+	result = Rml::CreateString("Context::Render() stats:\n"
+							   "  Compile geometry: %zu\n"
+							   "  Render geometry: %zu\n"
+							   "  Release geometry: %zu\n"
+							   "  Texture load: %zu\n"
+							   "  Texture generate: %zu\n"
+							   "  Texture release: %zu\n"
+							   "  Scissor enable: %zu\n"
+							   "  Scissor set: %zu\n"
+							   "  Clip mask enable: %zu\n"
+							   "  Clip mask render: %zu\n"
+							   "  Transform set: %zu",
 		counters.compile_geometry, counters.render_geometry, counters.release_geometry, counters.load_texture, counters.generate_texture,
 		counters.release_texture, counters.enable_scissor, counters.set_scissor, counters.enable_clip_mask, counters.render_to_clip_mask,
 		counters.set_transform);

+ 3 - 4
Tests/Source/UnitTests/Animation.cpp

@@ -217,8 +217,8 @@ TEST_CASE("animation.decorator")
 			const double t_final = 0.1;
 
 			system_interface->SetTime(0.0);
-			String document_rml = Rml::CreateString(document_decorator_rml.size() + 512, document_decorator_rml.c_str(), test.from_rule.c_str(),
-				test.to_rule.c_str(), property_str, test.from.c_str(), property_str, test.to.c_str());
+			String document_rml = Rml::CreateString(document_decorator_rml.c_str(), test.from_rule.c_str(), test.to_rule.c_str(), property_str,
+				test.from.c_str(), property_str, test.to.c_str());
 
 			ElementDocument* document = context->LoadDocumentFromMemory(document_rml, "assets/");
 			Element* element = document->GetChild(0);
@@ -343,8 +343,7 @@ TEST_CASE("animation.filter")
 			const double t_final = 0.1;
 
 			system_interface->SetTime(0.0);
-			String document_rml = Rml::CreateString(document_filter_rml.size() + 512, document_filter_rml.c_str(), property_str, test.from.c_str(),
-				property_str, test.to.c_str());
+			String document_rml = Rml::CreateString(document_filter_rml.c_str(), property_str, test.from.c_str(), property_str, test.to.c_str());
 
 			ElementDocument* document = context->LoadDocumentFromMemory(document_rml, "assets/");
 			Element* element = document->GetChild(0);

+ 1 - 1
Tests/Source/UnitTests/Element.cpp

@@ -314,7 +314,7 @@ TEST_CASE("Element.ScrollIntoView")
 	{
 		for (int j = 0; j < 4; ++j)
 		{
-			cells[i][j] = document->GetElementById(CreateString(8, "cell%d%d", i, j));
+			cells[i][j] = document->GetElementById(CreateString("cell%d%d", i, j));
 			REQUIRE(cells[i][j]);
 		}
 	}

+ 3 - 3
Tests/Source/UnitTests/Localization.cpp

@@ -27,13 +27,13 @@
  */
 
 #include "../Common/TestsShell.h"
-#include <RmlUi/Core/Context.h>
 #include <RmlUi/Core/ComputedValues.h>
+#include <RmlUi/Core/Context.h>
 #include <RmlUi/Core/Core.h>
 #include <RmlUi/Core/Element.h>
 #include <RmlUi/Core/ElementDocument.h>
-#include <RmlUi/Core/StyleTypes.h>
 #include <RmlUi/Core/StringUtilities.h>
+#include <RmlUi/Core/StyleTypes.h>
 #include <doctest.h>
 
 using namespace Rml;
@@ -68,7 +68,7 @@ TEST_CASE("Localization")
 	Element* cells[4]{};
 	for (int i = 0; i < 4; ++i)
 	{
-		cells[i] = document->GetElementById(CreateString(8, "cell%d", i));
+		cells[i] = document->GetElementById(CreateString("cell%d", i));
 		REQUIRE(cells[i]);
 	}
 

+ 5 - 5
Tests/Source/UnitTests/StringUtilities.cpp

@@ -151,14 +151,14 @@ TEST_CASE("StringUtilities::ConvertCharacterOffsetToByteOffset")
 
 TEST_CASE("CreateString")
 {
-	CHECK(Rml::CreateString(0, "Hello %s!", "world") == "Hello world!");
-	CHECK(Rml::CreateString(0, "%g, %d, %.2f", 0.5f, 5, 2.f) == "0.5, 5, 2.00");
+	CHECK(Rml::CreateString("Hello %s!", "world") == "Hello world!");
+	CHECK(Rml::CreateString("%g, %d, %.2f", 0.5f, 5, 2.f) == "0.5, 5, 2.00");
 
 	constexpr int InternalBufferSize = 256;
 	for (int string_size : {InternalBufferSize - 1, InternalBufferSize, InternalBufferSize + 1})
 	{
 		Rml::String large_string(string_size, 'x');
-		CHECK(Rml::CreateString(0, "%s", large_string.c_str()) == large_string);
+		CHECK(Rml::CreateString("%s", large_string.c_str()) == large_string);
 	}
 }
 
@@ -166,7 +166,7 @@ TEST_CASE("FormatString")
 {
 	{
 		Rml::String result;
-		int length = Rml::FormatString(result, 0, "Hello %s!", "world");
+		int length = Rml::FormatString(result, "Hello %s!", "world");
 		CHECK(result == "Hello world!");
 		CHECK(length == 12);
 	}
@@ -176,7 +176,7 @@ TEST_CASE("FormatString")
 	{
 		const Rml::String large_string(string_size, 'x');
 		Rml::String result;
-		int length = Rml::FormatString(result, 0, "%s", large_string.c_str());
+		int length = Rml::FormatString(result, "%s", large_string.c_str());
 		CHECK(result == large_string);
 		CHECK(length == string_size);
 	}

+ 2 - 2
Tests/Source/VisualTests/CaptureScreen.cpp

@@ -110,7 +110,7 @@ ComparisonResult CompareScreenToPreviousCapture(Rml::RenderInterface* render_int
 		ComparisonResult result;
 		result.success = false;
 		result.error_msg =
-			Rml::CreateString(1024, "Could not read the captured screenshot from %s: %s", input_path.c_str(), lodepng_error_text(lodepng_result));
+			Rml::CreateString("Could not read the captured screenshot from %s: %s", input_path.c_str(), lodepng_error_text(lodepng_result));
 		return result;
 	}
 	RMLUI_ASSERT(w_ref > 0 && h_ref > 0 && data_ref);
@@ -205,7 +205,7 @@ ComparisonResult CompareScreenToPreviousCapture(Rml::RenderInterface* render_int
 		result.success = GenerateGeometry(*out_highlight, {diff.data.get(), image_ref_diff_byte_size}, {diff.width, diff.height});
 
 	if (!result.success)
-		result.error_msg = Rml::CreateString(1024, "Could not generate texture from file %s", input_path.c_str());
+		result.error_msg = Rml::CreateString("Could not generate texture from file %s", input_path.c_str());
 
 	return result;
 }

+ 8 - 8
Tests/Source/VisualTests/TestNavigator.cpp

@@ -510,7 +510,7 @@ void TestNavigator::StopTestSuiteIteration()
 				not_equal.push_back(i);
 		}
 
-		Rml::String summary = Rml::CreateString(256, "  Total tests: %d\n  Not equal: %d\n  Failed: %d\n  Skipped: %d\n  Equal: %d", num_tests,
+		Rml::String summary = Rml::CreateString("  Total tests: %d\n  Not equal: %d\n  Failed: %d\n  Skipped: %d\n  Equal: %d", num_tests,
 			(int)not_equal.size(), (int)failed.size(), (int)skipped.size(), (int)equal.size());
 
 		if (!suite.GetFilter().empty())
@@ -541,7 +541,7 @@ void TestNavigator::StopTestSuiteIteration()
 		for (int i : not_equal)
 		{
 			suite.SetIndex(i);
-			log += Rml::CreateString(512, "%5d   %5.1f%%  %4d   %s\n", i + 1, comparison_results[i].similarity_score * 100.0,
+			log += Rml::CreateString("%5d   %5.1f%%  %4d   %s\n", i + 1, comparison_results[i].similarity_score * 100.0,
 				(int)comparison_results[i].max_absolute_difference_single_pixel, suite.GetFilename().c_str());
 			if (!comparison_results[i].error_msg.empty())
 				log += "          " + comparison_results[i].error_msg + "\n";
@@ -550,26 +550,26 @@ void TestNavigator::StopTestSuiteIteration()
 		for (int i : failed)
 		{
 			suite.SetIndex(i);
-			log += Rml::CreateString(512, "%5d   %s\n", i + 1, suite.GetFilename().c_str());
+			log += Rml::CreateString("%5d   %s\n", i + 1, suite.GetFilename().c_str());
 			log += "          " + comparison_results[i].error_msg + "\n";
 		}
 		log += "\nSkipped:\n";
 		for (int i : skipped)
 		{
 			suite.SetIndex(i);
-			log += Rml::CreateString(512, "%5d   %s\n", i + 1, suite.GetFilename().c_str());
+			log += Rml::CreateString("%5d   %s\n", i + 1, suite.GetFilename().c_str());
 		}
 		log += "\nEqual:\n";
 		for (int i : equal)
 		{
 			suite.SetIndex(i);
-			log += Rml::CreateString(512, "%5d   %s\n", i + 1, suite.GetFilename().c_str());
+			log += Rml::CreateString("%5d   %s\n", i + 1, suite.GetFilename().c_str());
 		}
 		log += "\nEqual:\n";
 		for (int i : equal)
 		{
 			suite.SetIndex(i);
-			log += Rml::CreateString(256, "%5d   %s\n", i + 1, suite.GetFilename().c_str());
+			log += Rml::CreateString("%5d   %s\n", i + 1, suite.GetFilename().c_str());
 		}
 
 		const Rml::String log_path = GetCaptureOutputDirectory() + "/comparison.log";
@@ -597,7 +597,7 @@ void TestNavigator::UpdateGoToText(bool out_of_bounds)
 	if (out_of_bounds)
 		viewer->SetGoToText("Go To out of bounds");
 	else if (goto_index > 0)
-		viewer->SetGoToText(Rml::CreateString(64, "Go To: %d", goto_index));
+		viewer->SetGoToText(Rml::CreateString("Go To: %d", goto_index));
 	else if (goto_index == 0)
 		viewer->SetGoToText("Go To:");
 	else if (iteration_state == IterationState::Capture)
@@ -605,7 +605,7 @@ void TestNavigator::UpdateGoToText(bool out_of_bounds)
 	else if (iteration_state == IterationState::Comparison)
 		viewer->SetGoToText("Comparing all tests");
 	else if (reference_state == ReferenceState::ShowReference)
-		viewer->SetGoToText(Rml::CreateString(100, "Showing reference capture (%.1f%% similar)", reference_comparison.similarity_score * 100.));
+		viewer->SetGoToText(Rml::CreateString("Showing reference capture (%.1f%% similar)", reference_comparison.similarity_score * 100.));
 	else if (reference_state == ReferenceState::ShowReferenceHighlight)
 		viewer->SetGoToText("Showing reference capture (highlight differences)");
 	else

+ 4 - 4
Tests/Source/VisualTests/TestViewer.cpp

@@ -268,7 +268,7 @@ bool TestViewer::LoadTest(const Rml::String& directory, const Rml::String& filen
 		RMLUI_ASSERT(description_header);
 
 		description_header->SetInnerRML(
-			CreateString(512, "Test suite %d of %d<br/>Test %d of %d<br/>", suite_index + 1, number_of_suites, test_index + 1, number_of_tests));
+			CreateString("Test suite %d of %d<br/>Test %d of %d<br/>", suite_index + 1, number_of_suites, test_index + 1, number_of_tests));
 	}
 
 	// Description Filter
@@ -278,9 +278,9 @@ bool TestViewer::LoadTest(const Rml::String& directory, const Rml::String& filen
 		if (filtered_number_of_tests == 0)
 			description_filter_text->SetInnerRML("No matches");
 		else if (filtered_number_of_tests < number_of_tests && filtered_test_index >= 0)
-			description_filter_text->SetInnerRML(CreateString(128, "Filtered %d of %d", filtered_test_index + 1, filtered_number_of_tests));
+			description_filter_text->SetInnerRML(CreateString("Filtered %d of %d", filtered_test_index + 1, filtered_number_of_tests));
 		else if (filtered_number_of_tests < number_of_tests && filtered_test_index < 0)
-			description_filter_text->SetInnerRML(CreateString(128, "Filtered X of %d", filtered_number_of_tests));
+			description_filter_text->SetInnerRML(CreateString("Filtered X of %d", filtered_number_of_tests));
 		else
 			description_filter_text->SetInnerRML("");
 	}
@@ -288,7 +288,7 @@ bool TestViewer::LoadTest(const Rml::String& directory, const Rml::String& filen
 	// Description Content
 	{
 		String rml_description =
-			Rml::CreateString(512, "<h1>%s</h1><p><a href=\"%s\">%s</a>", document_test->GetTitle().c_str(), test_path.c_str(), filename.c_str());
+			Rml::CreateString("<h1>%s</h1><p><a href=\"%s\">%s</a>", document_test->GetTitle().c_str(), test_path.c_str(), filename.c_str());
 
 		if (!reference_filename.empty())
 		{