From 3166392242437ccdbda0958ff6b7fd8e7923fb5c Mon Sep 17 00:00:00 2001 From: James Cherry Date: Sat, 9 Nov 2024 20:42:26 -0800 Subject: [PATCH] makeTmpString Signed-off-by: James Cherry --- util/StringUtil.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/util/StringUtil.cc b/util/StringUtil.cc index 02c5edfc..bdde20e1 100644 --- a/util/StringUtil.cc +++ b/util/StringUtil.cc @@ -20,12 +20,15 @@ #include #include #include +#include #include "Machine.hh" #include "Mutex.hh" namespace sta { +using std::max; + static void stringPrintTmp(const char *fmt, va_list args, @@ -199,9 +202,10 @@ makeTmpString(size_t length) if (tmp_length < length) { // String isn't long enough. Make a new one. delete [] tmp_str; - tmp_str = new char[length]; + tmp_length = max(tmp_string_initial_length, length); + tmp_str = new char[tmp_length]; tmp_strings[tmp_string_next] = tmp_str; - tmp_string_lengths[tmp_string_next] = length; + tmp_string_lengths[tmp_string_next] = tmp_length; } tmp_string_next++; return tmp_str;