summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/CommandObject.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2012-05-26 17:21:14 +0000
committerGreg Clayton <gclayton@apple.com>2012-05-26 17:21:14 +0000
commitd70b14ea9dcbb907a5a58fee415e8e0679a595a1 (patch)
treec36371ea66ad36cd714e52786c6f648c5b36e804 /lldb/source/Interpreter/CommandObject.cpp
parent3c05cd3ea8d9073fcf6fab35755c2ef9343c63a6 (diff)
downloadbcm5719-llvm-d70b14ea9dcbb907a5a58fee415e8e0679a595a1.tar.gz
bcm5719-llvm-d70b14ea9dcbb907a5a58fee415e8e0679a595a1.zip
Fixed memory management issues introduced by revision 157507.
A local std::string was being filled in and then the function would return "s.c_str()". A local StreamString (which contains a std::string) was being filled in, and essentially also returning the c string from the std::string, though it was in a the StreamString class. The fix was to not do this by passing a stream object into StringList::Join() and fix the "arch_helper()" function to do what it should: cache the result in a global. llvm-svn: 157519
Diffstat (limited to 'lldb/source/Interpreter/CommandObject.cpp')
-rw-r--r--lldb/source/Interpreter/CommandObject.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp
index c86bb5e9f7e..af9aa39e7ed 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -849,12 +849,15 @@ CommandObject::GetArgumentDescriptionAsCString (const lldb::CommandArgumentType
static
const char *arch_helper()
{
- StringList archs;
- ArchSpec::AutoComplete(NULL, archs);
- StreamString ss;
- ss.Printf("These are the supported architecture names:\n");
- ss.Printf("%s\n", archs.Join("\n"));
- return ss.GetData();
+ static StreamString g_archs_help;
+ if (g_archs_help.GetData() == NULL)
+ {
+ StringList archs;
+ ArchSpec::AutoComplete(NULL, archs);
+ g_archs_help.Printf("These are the supported architecture names:\n");
+ archs.Join("%s\n", g_archs_help);
+ }
+ return g_archs_help.GetData();
}
CommandObject::ArgumentTableEntry
OpenPOWER on IntegriCloud