summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/StringList.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/Core/StringList.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/Core/StringList.cpp')
-rw-r--r--lldb/source/Core/StringList.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/lldb/source/Core/StringList.cpp b/lldb/source/Core/StringList.cpp
index 88dd2edb3f8..c4356e7eccc 100644
--- a/lldb/source/Core/StringList.cpp
+++ b/lldb/source/Core/StringList.cpp
@@ -95,23 +95,20 @@ StringList::GetStringAtIndex (size_t idx) const
return NULL;
}
-const char *
-StringList::Join (const char *separator)
+void
+StringList::Join (const char *separator, Stream &strm)
{
uint32_t size = GetSize();
+
if (size == 0)
- return "";
- if (size == 1)
- return GetStringAtIndex(0);
-
- std::string buf;
+ return;
+
for (uint32_t i = 0; i < size; ++i)
{
if (i > 0)
- buf.append(separator);
- buf.append(GetStringAtIndex(i));
+ strm.PutCString(separator);
+ strm.PutCString(GetStringAtIndex(i));
}
- return buf.c_str();;
}
void
OpenPOWER on IntegriCloud