summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/CommandInterpreter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Interpreter/CommandInterpreter.cpp')
-rw-r--r--lldb/source/Interpreter/CommandInterpreter.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 2a84eef91f1..b6cd3c73818 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1687,12 +1687,17 @@ CommandInterpreter::OutputFormattedHelpText (Stream &strm,
int indent_size = max_word_len + strlen (separator) + 2;
strm.IndentMore (indent_size);
-
- int len = indent_size + strlen (help_text) + 1;
- char *text = (char *) malloc (len);
- sprintf (text, "%-*s %s %s", max_word_len, word_text, separator, help_text);
+
+ StreamString text_strm;
+ text_strm.Printf ("%-*s %s %s", max_word_len, word_text, separator, help_text);
+
+ size_t len = text_strm.GetSize();
+ const char *text = text_strm.GetData();
if (text[len - 1] == '\n')
- text[--len] = '\0';
+ {
+ text_strm.EOL();
+ len = text_strm.GetSize();
+ }
if (len < max_columns)
{
@@ -1750,7 +1755,6 @@ CommandInterpreter::OutputFormattedHelpText (Stream &strm,
}
strm.EOL();
strm.IndentLess(indent_size);
- free (text);
}
void
OpenPOWER on IntegriCloud